listscript_htm.cgi
#!/usr/bin/perl
#%% Print script source in html | GEN | --
#________________________________________________________
$|=1;
use CGI ':standard';
$file = param('file') || $0;# File to be listed - list this one if not given
$ss = param('ss');# Search String
print header, "<body bgcolor=white>",
"<div align=right><h3><font color=blue>$file</font></h3></div>";
open (FF, $file) || error ("$file - $!");
print start_form,"Search for: ",textfield(-name=>'ss'), ' ', submit('Submit'),
hidden('file', $file), end_form;
for (<FF>) {
s/</</og;# Convert angle brackets
s/>/>/og;# to show tags without interpreting them
s/\t/<dd>/og;# convert tabs to <dd>s
s/ / /og;# and spaces to
s/\n$/<br>/og;# replace new lines @ the end of line to <br>
s/\Q$ss\E/<font size=+1 color=red>$ss<\/font>/ogi; # Highlight search strings
print;
}
sub error {
print "<h2>Error</h2>",shift;# show error before dying
die;
}