From: darren chamberlain <[EMAIL PROTECTED]>
   Date: Mon, 10 Feb 2003 12:22:29 -0500

   . . .

   > I then tried, just for the heck of it, changing the 'my' declarations
   > into 'our' declarations.  But this didn't help.

   Using "our" should work, provided you reference the variables with their
   full names:

     $Some::Variable::In::Another::Package = "foo";

But "man perlfunc" says the following in the "our" entry:

        An "our" declaration declares a global variable that will be
        visible across its entire lexical scope, even across package
        boundaries.  The package in which the variable is entered is
        determined at the point of the declaration, not at the point of
        use.  This means the following behavior holds:

            package Foo;
            our $bar;           # declares $Foo::bar for rest of lexical scope
            $bar = 20;

            package Bar;
            print $bar;         # prints 20

This is in perl5/5.6.1/pod/perlfunc.pod, but "our" seems to have evolved
recently (while I wasn't watching), so maybe it doesn't work this way in
older versions?

   In any case, the important point is that "our" variables are scoped
to the file (strictly, the rest of the file after the point of
declaration).  Does that maybe explain why "our" didn't seem to work?

                                        -- Bob Rogers
                                           http://rgrjr.dyndns.org/
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to