<?xml version="1.0" encoding="windows-1252"?>
<node id="314681" title="$_ and list flattening with map()" created="2003-12-14 16:05:31" updated="2005-07-25 21:41:59">
<type id="115">
perlquestion</type>
<author id="272239">
liz</author>
<data>
<field name="doctext">
[Aristotle]'s answer to [id://314423] made me find the following phenomenon:
&lt;code&gt;
$a = [[0]];
foreach (@$a) { $_++ foreach @$_ }
print $a-&gt;[0][0],$/;
$_++ for map @$_, @{$a};
print $a-&gt;[0][0],$/;
__END__
1
1
&lt;/code&gt;
The expected output is:
&lt;code&gt;
1
2
&lt;/code&gt;
The strange thing is that the extra list flattening with map() doesn't work.  I don't see any reason why it shouldn't.  I guess the question is: is this a bug or not?
&lt;P&gt;
Liz
&lt;P&gt;
&lt;B&gt;Update&lt;/B&gt;:&lt;BR&gt;
Not a bug, just copying of the list with map().  Thanks to [!1], [blokhead] and [holo] for the enlightenment.</field>
</data>
</node>
