use strict; use warnings; use LWP::Simple; use HTML::Strip; my $url = "http://www.expressen.se/ekonomi/1.1805368/reinfeldt-forsvarar-nya-sjukregler"; my $html = get($url); defined $html or die "Can't fetch HTML from: ",$url; my $hs = HTML::Strip->new(); my $clean_text = $hs->parse( $html ); $hs->eof; #sentences spread across multiple lines $clean_text =~ s/(\n)/ /g; $clean_text =~ s/(\r)/ /g; #compact double white space into dots $clean_text =~ s/(\s){2,}/./g; #compact dots into single dots $clean_text =~ s/(\.){2,}/\./g; #split sentances on dots my @sentences = split(/\./, $clean_text); my @realSentences = (); #ignore sentences with single words foreach my $sentence (@sentences) { if(($sentence =~ tr/ //)>1) { push @realSentences, $sentence; } } foreach (@realSentences) { print "$_\n"; }