Hi all
Im fairly new to perl so bear with me!
Just wondered if someone can help me..
Ive got two perl subs and want to pass variables from one to the other and then return a result.
IE:
1st sub contains this code :
@linkage = findlinkage($url,$required,$title);
The findlinkage sub is below:
sub findlinkage($urla, $requireda, $titlea){
$ua = LWP::UserAgent->new;
# Set up a callback that collect image links
my @imgs = ();
my($tag, %attr) = @_;
return if $tag ne 'a'; # we only look closer at <img ...>
push(@imgs, values %attr);
# Make the parser. Unfortunately, we don't know the base yet
# (it might be diffent from $url)
$p = HTML::LinkExtor->new(\&callback);
# Request document and parse it as it arrives
$res = $ua->request(HTTP::Request->new(GET => $url),
sub {$p->parse($_[0])});
# Expand all image URLs to absolute ones
my $base = $res->base;
@imgs = map { $_ = url($_, $base)->abs; } @imgs;
# Print them out
print join("\n", @imgs), "\n";
return @alinks;
}
im getting an error of:
Illegal character in prototype for main::findlinkage : $urla,$requireda,$titlea at /perl/site/lib//findlinks.pm line 11.
Any one help me?
Line 11 is the first line in the sub: IE:sub findlinkage($urla, $requireda, $titlea){
Im a VB programmer and this is the way i pass arguments in VB, is Perl completely different? i cant manage to track down much documentation on this.
Thanks for any help!!
regards
Nash
Im fairly new to perl so bear with me!
Just wondered if someone can help me..
Ive got two perl subs and want to pass variables from one to the other and then return a result.
IE:
1st sub contains this code :
@linkage = findlinkage($url,$required,$title);
The findlinkage sub is below:
sub findlinkage($urla, $requireda, $titlea){
$ua = LWP::UserAgent->new;
# Set up a callback that collect image links
my @imgs = ();
my($tag, %attr) = @_;
return if $tag ne 'a'; # we only look closer at <img ...>
push(@imgs, values %attr);
# Make the parser. Unfortunately, we don't know the base yet
# (it might be diffent from $url)
$p = HTML::LinkExtor->new(\&callback);
# Request document and parse it as it arrives
$res = $ua->request(HTTP::Request->new(GET => $url),
sub {$p->parse($_[0])});
# Expand all image URLs to absolute ones
my $base = $res->base;
@imgs = map { $_ = url($_, $base)->abs; } @imgs;
# Print them out
print join("\n", @imgs), "\n";
return @alinks;
}
im getting an error of:
Illegal character in prototype for main::findlinkage : $urla,$requireda,$titlea at /perl/site/lib//findlinks.pm line 11.
Any one help me?
Line 11 is the first line in the sub: IE:sub findlinkage($urla, $requireda, $titlea){
Im a VB programmer and this is the way i pass arguments in VB, is Perl completely different? i cant manage to track down much documentation on this.
Thanks for any help!!
regards
Nash