Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Constant variables

by integral (Hermit)
on Apr 27, 2003 at 08:33 UTC ( #253457=note: print w/ replies, xml ) Need Help??


in reply to Constant variables

unless isn't a looping construct, it's a branching/control construct, but that's not important, what is important is the scoping of the $errorcount variable (see Coping with scoping as usual). You need to define the variable in the containing scope of the unlesses and the if.

If you declare the variable once within each block you will be accessing a different variable in the block. If you want to access the same variable it must be declared at a containing scope so that it is visible (a containing lexical scope if you're using lexicals, and a containing dynamic scope if you're using package globals, which you shouldn't be for something like this)

--
integral, resident of freenode's #perl


Comment on Re: Constant variables
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-11-24 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (147 votes), past polls