in reply to $_ and list flattening with map()
The difference is that you do the increment outside of the scope in which map aliases $_. This foreach is iterating over the return value of map, which is a list of copies (not aliases back into @$a). foreach now aliases $_ to this anonymous list of copies, so your modifications to $_ are lost.$_++ for map @$_, @{$a};
If you use map as a control structure (making it more of a direct translation of the first example), and do the increment inside map's block, you'll get what you expected originally:
map { map { $_++ } @$_ } @$a;
blokhead
In Section
Seekers of Perl Wisdom