#!/usr/bin/perl # In use with lighttpd's server.errorfile-prefix option use strict; use warnings; my @errors = ( [ '401', 'Unauthorized access' ], [ '403', 'Access forbidden' ], [ '404', 'Document not found' ], [ '500', 'Internal Server Error' ], ); foreach my $error (@errors) { my $code = $error->[0]; unlink "$code.html"; } my $template = do { local $/; }; foreach my $error (@errors) { my ($code, $message) = @$error; my $output = do { local $_ = $template; s/\$TITLE/$message ($code)/; s/\$MESSAGE/$message!/; $_ }; my $output_filename = "$code.html"; open(my $fh, '>', $output_filename) or die "Cannot open $output_filename for writing: $!\n"; print {$fh} $output; close($fh); } __DATA__ $TITLE

$MESSAGE

Back to main page