I have an array of HTML::Elements obtained from HTML::TreeBuilder and HTML::Element->find and I need to assign their as_text value to some other variables. I know I can really easily do
my ($var1, $var2) = ($arr[0]->as_text, $arr[1]->as_text);
but I was hoping I could use map instead just to make the code a bit more readable as there are at least 8 elements in the array. I’m really new to Perl so I’m not quite sure what to do.
Can anyone point me in the right direction?
If you’re well versed in
perldoc -f mapit’s pretty clear:Works as well if you want to assign to a list of scalars:
But of course the array version is better for an unknown number of elements.