You need to pass a reference to an array. I'd probably
declare @array first and then use \@array,
but merlyn has done both in one step (I didn't know you
could do that - never too old to learn new stuff I suppose!)
map is an operator that takes a block of code
and an array. It runs (and returns the results of running)
the block of code once for each element in the array. Each
element is aliased to $_ within the block.
When you pass an array ref, instead of a sub ref, to
HTML::Parser->new it will store all of the values
that would have been parameters to the handler, in the
array. In our case it's just one value ('text') but it
could well be more. Because of that, the array is in fact
an array of arrays (or, more accurately, an array of
Therefore each time the map block is called,
$_ contains a reference to a one-element array
and $_-> contains the value of the first
(and only) element in that array. The whole map
call returns the complete list of these elements,
effectively flattening the array to one dimension.
Just by way of handing you a fishing pole, note that for just about any function in Perl, perldoc -f [function_name] will tell you what it does and how to use it. You can also Search on this site to see other Q&A's. I also like to point folks to the Tutorials section, as much wisdom is contained therein.
Philosophy can be made out of anything. Or less -- Jerry A. Fodor