#!/usr/bin/perl use strict; use warnings; my $the_file; use LWP::Simple; #$the_file = get("http://www.perlmonks.org"); # or $the_file = get("http://search.yahoo.com/search?p=hotel&fr=yfp-t-103&toggle=1&cop=mss&ei=UTF-8"); use HTML::Parser; my $parser = HTML::Parser->new( text_h => [ \&text_handler,"self,dtext" ], start_document_h => [\&init, "self"] ); $parser->parse($the_file); print @{$parser->{_private}->{text}}; sub init { my ( $self ) = @_; $self->{_private}->{text} = []; } sub text_handler { my ( $self, $text) = @_; push @{$self->{_private}->{text}}, $text; }