use strict; use warnings; use 5.010; use LWP::Simple; use HTML::TreeBuilder; my $html =<<'END_HTML';
Hi

Thanks

Hello
END_HTML my $tree = HTML::TreeBuilder->new_from_content($html); my @spans = $tree->look_down(class => 'value'); for my $span (@spans) { say $span->as_trimmed_text(); } $tree->delete(); --output:-- Hi Hello #### use strict; use warnings; use 5.010; use LWP::Simple; use HTML::TreeBuilder; my $url = 'http://www.almanac.com/weather/history/zipcode/21218/2008-09-02'; my $html = get($url); my $tree = HTML::TreeBuilder->new(); $tree->parse_file($html); my $span_tag = $tree->look_down( class => 'value', ); say $span_tag->as_trimmed_text(); $tree->delete(); --output:-- Can't call method "as_trimmed_text" on an undefined value at 1perl.pl line 41.