Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: "map" sometimes uses only the last mapped value

by Anonymous Monk
on Apr 18, 2006 at 12:55 UTC ( #544056=note: print w/replies, xml ) Need Help??


in reply to "map" sometimes uses only the last mapped value

It seems to have to do with returning a temp from inside a for loop. It's not just stringify, here:
print map sub{return $_ for 0+shift}->($_), 1, 2, 3; # 333 print map sub{return $_ for shift}->($_), 1, 2, 3; # 123 print map sub{return 0+shift}->($_), 1, 2, 3; # 123 print map sub{return 0+$_ for shift}->($_), 1, 2, 3; # 123
Only the first of these cases messes up, funny

Replies are listed 'Best First'.
Re^2: "map" sometimes uses only the last mapped value
by xmath (Hermit) on Apr 18, 2006 at 12:56 UTC
    That was my post, forgot to log in. Sorry :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2022-05-23 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (81 votes). Check out past polls.

    Notices?