Patrik Hasibuan wrote:
Dear my friends...
Hello,
I want to take all the strings between "<a .... class=l>" and "</a>" and put it
into array.
I do this way but it does not work properly:
Put these two lines at the start of your program:
use warnings;
use strict;
$kontenurl=eksekusi->baru();
eksekusi is a bareword, it should probably be $eksekusi.
$_=$kontenurl->gogeturl("$assprm{'kwnya'}", "$urlnya", "$nohal");
print "$_";
You shouldn't quote variables:
$_ = $kontenurl->gogeturl( $assprm{'kwnya'}, $urlnya, $nohal );
print $_;
But why not just:
print $kontenurl->gogeturl( $assprm{'kwnya'}, $urlnya, $nohal );
print "<hr>";
print "<table border=1>";
$i=0;
my $i = 0;
while (<>){
@result[$i]=substr($_, index($_,"<a. class=l>"), index($_, "</a>"));
@result[$i] is a list. You want to use a scalar:
$result[$i] = substr($_, index($_,"<a. class=l>"), index($_, "</a>"));
Or better yet, use push:
push @result, substr($_, index($_,"<a. class=l>"), index($_, "</a>"));
The third argument of substr() is the length of the string you want but
index() returns the offset of the location of the sub-string. Also there
could be an "</a>" string *before* the "<a. class=l>" string in $_.
print "<tr><td>";
print "@result[$i]";
print $result[ $i ];
print "</td></tr>";
$i++;
}
print @result;
print "</table>";
Please tell me where my mistake.
Use a module that understands HTML and can parse it correctly.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/