Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

RE: Re: i thought i knew 'our'...

by autark (Friar)
on Jul 24, 2000 at 21:11 UTC ( #24128=note: print w/replies, xml ) Need Help??


in reply to Re: i thought i knew 'our'...
in thread i thought i knew 'our'...

'our' and 'my' are two very different beasts. You can not substitute 'our' with 'my' or vice versa, take this as an example:
use strict; { our $y; $y = 17; print "Inner: $y\n"; } our $y; print "Outer: $y\n";
That will print:
Inner: 17
Outer: 17
Now, if you substituted our with my (s/our/my/g) then it would print:
Inner: 17
Outer:
...and it would complain about use of uninitialized variable :-)

Autark.

Replies are listed 'Best First'.
RE: RE: Re: i thought i knew 'our'...
by monk (Scribe) on Jul 24, 2000 at 21:17 UTC
    you are right, what i meant was that our could be use to declare variables in the begining
    of a program like:
    #!/usr/bin/perl -w use strict; our($foo,@bar,%args); <- this was what i meant.
    Not to s/my/our/; as you pointed out. Sorry didn't explain myself quite right.
    monk

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-11-30 05:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?