Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Last undefines a for loop's itererator?

by jonix (Friar)
on Nov 14, 2005 at 11:13 UTC ( [id://508270]=note: print w/replies, xml ) Need Help??


in reply to Re: Last undefines a for loop's itererator?
in thread Last undefines a for loop's itererator?

OK, I guess your remark confuses me a bit:
What do you mean with for/foreach clobbering up $_?
Is $_ not always implicitly localized in these looping constructs as a lexical (while while is not really a looping construct) - what is the problem with using $_?

Cheers,
jonix
  • Comment on Re^2: Last undefines a for loop's itererator?

Replies are listed 'Best First'.
Re^3: Last undefines a for loop's itererator?
by ivancho (Hermit) on Nov 14, 2005 at 17:30 UTC
    $_ is, indeed, localized in for(|each) loops. I was using this to support the claim that any other (explicit) loop variable would be better off localized too. Using $_ is, of course, perfectly fine.
    I quite like ewilhelm's point - if one wants a loop that behaves like a function, why not write one.

    I guess there's some sort of linguistic argument here as well - if we say "This cow is green. Each cow in the field is purple. The cow has red eyes", in the last sentence 'cow' has clearly reverted to mean the first cow again, even though it's been pointing to other cows in the 'Each' sentence..

      Thanks, it seems I simply understood you wrong.
      I often like to pronounce $_ as "it" for myself, as "dollar-underscore" is too long and meaningless. How do you pronounce $_ when talking about it btw.?
        I usually don't talk about $_ .. ;-)
        but yeah, it is what it generally stands for.. :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found