Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: 'our' is not 'my'

by ruzam (Curate)
on Oct 26, 2007 at 16:37 UTC ( [id://647431]=note: print w/replies, xml ) Need Help??


in reply to Re^3: 'our' is not 'my'
in thread 'our' is not 'my'

I guess that also explains why I can put 'our $var;' in package BB and have this version of $var carried through main. Each use of 'our' replaces any previous alias for the remainder of the execution. I'll have to re-train my brain on what to expect from packages :)

Makes me a little nervous that Perl would allow this without some kind of warning. Also makes me wonder what kind of problems could be made easier using 'our' in this way?

Replies are listed 'Best First'.
Re^5: 'our' is not 'my'
by JadeNB (Chaplain) on Nov 26, 2008 at 15:30 UTC
    The point is that Perl is willing to trust you. Your telling it our $var means “I and all my friends in this lexical scope want to use this variable without qualification” (that's why it's the first person plural!). Since it believes that you know what you're doing, it doesn't want to warn you later when you do just what you said that you were going to do.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found