gorilla1
03-10-2010, 10:29 PM
I am unfortunately very rusty with Perl and I am trying to build a script where I read a file and when I find a certain string in each line I want to do a database lookup and then add a hyperlink.
The loop as I read each record from the file is below. What I can't figure out is how to call the subroutine -- it just prints out as the name of the subroutine (&getpage).
while (<FILE>) {
if (/\>line\|/) {
s{(\>line\|[^\s]*)} {<A HREF=" &getpage($1) ">$1</A>}gs;
}
print "$_";
}
sub getlink {
my $link_index = shift;
my $link;
do some lookup for line here
return $link;
}
G
The loop as I read each record from the file is below. What I can't figure out is how to call the subroutine -- it just prints out as the name of the subroutine (&getpage).
while (<FILE>) {
if (/\>line\|/) {
s{(\>line\|[^\s]*)} {<A HREF=" &getpage($1) ">$1</A>}gs;
}
print "$_";
}
sub getlink {
my $link_index = shift;
my $link;
do some lookup for line here
return $link;
}
G