Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Using guards for script execution?

by RonW (Parson)
on Mar 03, 2017 at 00:13 UTC ( [id://1183492]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using guards for script execution?
in thread Using guards for script execution?

provide a namespace that was not package-level to prevent accidental use of "global" variables

For clarification:

Variables declared with my are not package variables. At file-level, they are file scoped, so will be accessible from the declaration until the end of file. When declared inside a block, they are only accessible until the end of that block.

Package variables are declared with our or use vars and are accessible from inside the package they are declared in.

Also, package variables can be accessed by their fully qualified names from anywhere. So, in that sense, are also "global".

Replies are listed 'Best First'.
Re^4: Using guards for script execution?
by R0b0t1 (Initiate) on Mar 03, 2017 at 14:52 UTC

    Right, I'm referring to the unusual case where one accidentally makes use of a variable without redeclaring it and thus unintentionally modifies it in some enclosing scope.

    It doesn't happen often but is something I remember doing.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2026-04-11 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.