CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Issue with hashing get_tag values

 



buli
Novice

Nov 3, 2011, 6:47 AM

Post #1 of 1 (262 views)
Issue with hashing get_tag values Can't Post

I'm using the following to get some tag attributes from a html page:


Code
while ( $tag = $stream->get_tag("h2") ) { 


$tag = $stream->get_tag('a');

$url = $tag->[1]{href};

$headline = $stream->get_trimmed_text('/a');

$tag = $stream->get_tag('img');
$pic = $tag->[1]{'src'};
$pic = substr($pic, 151);

next if $news{$url};

%news = (
"url" => $url,

"title" => $headline,

"image" => $pic,
);
push(@news_array, \%news);

};

for $h ( @news_array ) {
print "{ ";
for $r ( keys %$h ) {
print "$r= $h->{$r} ";
}
print "}\n";
}


but the fields "url" and "title" appear with the same repeating value, while the field "image" of the hash appears as empty. any idea?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives