I found this giblet of perl in a folder on the website that i am taking over at work. Not being a programmer or scripter, i cannot really understand what it is trying to do or whether i want to find out. So i ask if someone would be able to translate for me:
#!/usr/bin/perl -w
use CGI qw(:standard);
($volume) = @ARGV;
#! EDIT THE NEXT TWO LINES ONLY - SEE README FILE FOR INSTRUCTIONS
my $idxroot = "/Inetpub/wwwroot/ccgh/"; #path of server
my $docroot = "http://www.myserver.com/"; #location (URL) of server (REPLACE www.myserver.com with the name of your web server)
#! DO NOT EDIT ANYTHING BELOW THIS LINE
my $searchkey = param("find"); #search field from input form
open(INDEX, $idxroot . $volume . "gob.idx") || die "Can't open: $!";
$title = <INDEX>; #use first line of index file for title
print <<End_start;
Content-type: text/html
<html>
<head><TITLE>$title
</TITLE></head>
<BODY bgcolor=#FFFFFF>
<h3><center>$title
</center></h3></head>
<HR size=3>
<h4><em>Search Results for <u>$searchkey</u>:</em></h4>
<table cellspacing=5><tr>
End_start
if ($searchkey){
@hdrs = split /~/, <INDEX>;
$ncol=@hdrs;
for($i=1; $i<$ncol; $i++) {
print "<th valign=bottom>$hdrs[$i]<hr></th>";
}
print "</tr>
";
#Take care of wildcards in ICD-9 codes:
if($searchkey=~/\.[0-9xX\*\?\+][0-9xX\*\?\+]/){ #Found two decimal places
$searchkey =~ s/[xX\*\?\+]/\\w\*/g; #replace wildcard with PERL wildcard
$searchkey =~ s/\.([0-9])/\.\[\1xX\]/; #replace first decimal place with that digit or an X
$searchkey =~ s/([0-9]$)/\[\1xX\]/; #replace last decimal place with that digit or an X
$searchkey =~ /\Q$searchkey\E/; #precede non-alpha numeric characters with a backslash
}
elsif ($searchkey=~/\.[0-9xX\*\?\+]/){ #Found one decimal place
$searchkey =~ s/[xX\*\?\+]/\\w\*/;
$searchkey =~ s/\.([0-9])/\.\[\1xX\]\\w\*/;
$searchkey =~ /\Q$searchkey\E/;
}
elsif ($searchkey=~/\./){ #Found a period in searchkey
$searchkey =~ s/\.//; #Remove it from searchkey
}
while(<INDEX>){
if(/\b$searchkey/i){ #Found match (allow partial words)
$count++;
@fields = split(/~/);
print "<tr><td valign=top><a href=".$docroot.$volume.$fields[0].">$fields[1]</a></td>";
for($i=2; $i<$ncol; $i++) {
print "<td valign=top>".$fields[$i]."</td>";
}
print "</tr>
";
}
}
} #End of if($searchkey)
if(!$count){
print "<p>No Matches Found</p>";
}
print <<All_Done;
</table>
</BODY>
</html>
All_Done