You may have accepted an answer, but you should look at XML::Parser and HTML::TreeBuilder.
Rather than stripping out parts of the HTML Document, you are probably more interested in drilling down to the part of the document you want (eg everything in <body>
or a certain div
inside of it), which is why you most likely want something that one of the above modules provide. Not to mention, parsers can be used to do their best at removing all HTML elements and returning only text/CData.
How to delete a newline if it is the last character in a file?
How to pass command-line arguments to a Perl program?
How to efficiently calculate a running standard deviation
Howto use a variable in the replacement side of the Perl substitution operator?
How to summ quickly all numbers in a file?
How to remove duplicate items from an array in Perl?
How to differ of Two Arrays Using Perl