Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: $_ and list flattening with map()

by !1 (Hermit)
on Dec 14, 2003 at 21:18 UTC ( #314683=note: print w/replies, xml ) Need Help??


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

I always thought map just returns copies of the values?

my @a = qw(1 2); my @b = \(@a); my @c = \(map $_,@a); print "Addresses do not match$/" unless "@b" eq "@c"; __END__ Addresses do not match

Of course, changing your map to:

${$_}++ for map \(@$_),@{$a};

Will make it work as expected.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://314683]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-02-22 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (300 votes). Check out past polls.

    Notices?