Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Just another Perl shrine
 
PerlMonks  

Re: $_ and list flattening with map()

by pg (Canon)
on Dec 14, 2003 at 22:05 UTC ( #314690=note: print w/ replies, xml ) Need Help??


in reply to $_ and list flattening with map()

This tells why:

use strict; use warnings; use Data::Dumper; my $a = [[0,1,2], [10,11,12]]; print \$a->[0][0], "\n"; print \$a->[0][1], "\n"; print \$a->[0][2], "\n"; print \$a->[1][0], "\n"; print \$a->[1][1], "\n"; print \$a->[1][2], "\n"; print "=======\n"; print \$_, "\n" for map @$_, @{$a};#one of your way print "=======\n"; foreach (@$a) { print \$_, "\n" foreach @$_ }#your other way

Result, see how the 3rd set is the same as the 1st one, but the 2nd set stands alone:

SCALAR(0x15551a4) SCALAR(0x15551b0) SCALAR(0x15551c8) SCALAR(0x155abd4) SCALAR(0x155500c) SCALAR(0x1571284) ======= SCALAR(0x15712c0) SCALAR(0x1571290) SCALAR(0x15551d4) SCALAR(0x15712e4) SCALAR(0x15712d8) SCALAR(0x15712cc) ======= SCALAR(0x15551a4) SCALAR(0x15551b0) SCALAR(0x15551c8) SCALAR(0x155abd4) SCALAR(0x155500c) SCALAR(0x1571284)


Comment on Re: $_ and list flattening with map()
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://314690]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2014-04-18 19:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls