Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: $_ and list flattening with map()

by holo (Monk)
on Dec 14, 2003 at 21:44 UTC ( #314687=note: print w/replies, xml ) Need Help??


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

The line:

$_++ for map $_, @a;

generates an anonymous list with map, then iterates through it with for incrementing all its values. Once for is done, the list is thrown away (expensive no-op).

The line:

$_++ for my @b = map $_, @a;

generates a list with map and throws it in @b, then iterates through it with for incrementing all values as before. This time, the list is not anonymous and may be accessed by using @b and it's not thrown away. Once map is evaluated, values in @b are totaly independent from values in @a.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://314687]
help
Chatterbox?
[shmem]: well, previous to that << was always treated as the left-shift operator
[Eily]: or the here-doc operator
[Eily]: which is actually how it is parsed in this case
[shmem]: older versions of perl can't guess that "use of <<>> may be implemented someday" :D
Discipulus how much wise my brothers are? ;=)
[karlgoethebier]: thanks ;-
[karlgoethebier]: ...to all for reading the manuals

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2017-07-21 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (320 votes). Check out past polls.