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

Re^2: Auto-incrementing strings in for loops

by JadeNB (Chaplain)
on Nov 20, 2009 at 04:19 UTC ( #808334=note: print w/replies, xml ) Need Help??


in reply to Re: Auto-incrementing strings in for loops
in thread Auto-incrementing strings in for loops

it seems to me that for part 2 you are 'say'ing the for loop and thus $_ will be the constant 1 then 2.
Thanks for your thoughts, but the parsing you suggest is not quite right:
$ perl5.10 -MO=Deparse,-p -E 'say for 1..2' BEGIN { $^H{'feature_say'} = q(1); $^H{'feature_state'} = q(1); $^H{'feature_switch'} = q(1); } ; say($_) foreach (1 .. 2); -e syntax OK
That is, say for ... is understood as say($_) for .... The problem is, unfortunately, much sillier than that: for aliases $_, so I wasn't incrementing the variable that I thought I was incrementing!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2021-05-13 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (134 votes). Check out past polls.

    Notices?