Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: 'Our' limits?

by jmcada (Acolyte)
on Jul 14, 2006 at 16:44 UTC ( [id://561263]=note: print w/replies, xml ) Need Help??


in reply to 'Our' limits?

I think you'll still have to reference the package that the 'our' variable is declared in. The doc is just saying that you can see the 'our' variable in other packages. It doesn't state how you have to refer to it. (See $Foo::d below)
package Foo; sub top { my($fn) = @_; our($d) = ["a", "b"]; printf "Top before %s [%s]\n", $d, join(",", @$d); $fn->($d); printf "Top After %s [%s]\n", $d, join(",", @$d); } package Bar; Foo::top(sub { our($d) = @_; printf " Before %s [%s]\n", $d, join(",", @$d); $Foo::d = []; printf " After %s [%s]\n", $d, join(",", @$d); }); --(0)> perl test.pl Top before ARRAY(0x8144234) [a,b] Before ARRAY(0x8144234) [a,b] After ARRAY(0x8144234) [a,b] Top After ARRAY(0x81442dc) []

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-16 07:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found