# Print a file, whilst escaping HTML: -
sub print_file ($) {
+ my ($urls) = '(' . join ('|', qw{
+ http
+ telnet
+ gopher
+ file
+ wais
+ ftp
+ } )
+ . ')';
+
+ my ($ltrs) = '\w';
+ my ($gunk) = '/#~:.?+=&%@!\-';
+ my ($punc) = '.:?\-';
+ my ($any) = "${ltrs}${gunk}${punc}";
my ($filename) = @_;
open(FILE, $filename) or die "Cannot open $filename: $!\n";
print "<pre>\n";
s/</</g;
s/>/>/g;
s/"/"/g;
+ s/\b($urls:[$any]+?)(?=[$punc]*[^$any]|$)/<a href="$1">$1<\/a>/igox;
print;
}
print "</pre>";