##Use the module HTML::Parser use HTML::Parser; my $returnText ; my $objParser; ##Take the function parameters into local variables my( $sourceFilePath) = "1.html"; ##Mention that the parsed file should be converted to text file $objParser = HTML::Parser->new(text_h => [ sub {$returnText .= shift},'dtext']) || die "Unable to create an object of HTML::Parser :: $!"; ##Parse the html file $objParser->parse_file($sourceFilePath); print $returnText;