Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: foreach-loop-local var in sub

by choroba (Abbot)
on Jan 21, 2013 at 15:58 UTC ( #1014475=note: print w/ replies, xml ) Need Help??


in reply to Re: foreach-loop-local var in sub
in thread foreach-loop-local var in sub

you have changed context and $i is uninitialized within that context and therefor you are going to print zeros
Not exactly true. Try with
foreach (qw(a b)) {
Update: Do not use numbers for testing behaviour, see Re^3: variable declaration question.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re^2: foreach-loop-local var in sub
Download Code
Re^3: foreach-loop-local var in sub
by blue_cowdawg (Monsignor) on Jan 21, 2013 at 16:10 UTC
        Not exactly true. Try with

    Eh? What do you mean by that? Trying the OPs code with your mod still gives the result that they are not after.


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (19)
As of 2014-11-26 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (171 votes), past polls