Hugh:
I'm not sure exactly what you are trying to accomplish. Do you simply
want to extract the text portions of an HTML file? Or are you trying
to get a formatted text rendition of an HTML file? or...?
If you just want to accumulate text, you are very close to being on
the right track. All you have to do is make sure that $alltext is in
a scope that you can get at it. Some over-engineered scripts which do
fancier versions of the same job can be found at:
http://slinky.scrye.com/~tkil/perl/#www
Typically, they are simply sensitive to what context they are in,
instead of just slurping all the text. My habit is to accumulate into
a value in the object hash, and then provide an accessor to that value
(see "FQParser::get_doc" in my "fully-qualify" script).
Hope this helps,
t.