#!/usr/bin/perl binmode(STDOUT, ":utf8"); syswrite STDOUT, "Content-type: text/html; charset=UTF-8\n\n"; if(scalar @ARGV != 1) { open ERROR, "<:utf8", "404.html"; while(!(eof ERROR)) { read ERROR, $line, 10; syswrite STDOUT, $line; } close ERROR; } else { $input = $ARGV[0]; open XREF, "<", "xref"; $filename = "404.html"; while(!(eof XREF)) { $line = ; chomp($line); $line =~ /([^ ^\t]+)[ \t]+([^ ^\t]+)[ \t]+([^ ^\t]+)/; $key = $1; $data1 = $2; $data2 = $3; if ($key =~ /^$input$/) { $filename = $data1; $stylesheet = $data2; } } close XREF; if (($filename =~ /^404\.html$/)) { open ERROR, "<:utf8", $filename; while(!(eof ERROR)) { read ERROR, $line, 10; syswrite STDOUT, $line; } close ERROR; } else { $command = "xml/sabcmd "; $command .= $stylesheet; $command .= " "; $command .= $filename; open XML, "$command|"; while($line = ) { chomp $line; syswrite STDOUT, "$line\n"; } close XML; } }