in reply to Sharing the scalar love?

When you use a module in a script, any variables defined in that module with our (instead of my) are automatically exported.

Alternatively, just declare the variable in one module (package) and refer to it using the package name, double colon, variable name.

--t. alex
Life is short: get busy!

Replies are listed 'Best First'.
Re: Re: Sharing the scalar love?
by chromatic (Archbishop) on Dec 22, 2003 at 21:08 UTC
    When you use a module in a script, any variables defined in that module with our (instead of my) are automatically exported.

    Can you post some code that demonstrates this?

      S.pm...

      package S; use strict; use warnings; our $x = 1;

      And here is a script using S.pm

      use strict; use warnings; use S; print $S::x; print "\n";

      Play that funky music white boy..

        Where's the export? Do you mean something besides "creates an entry in the caller's symbol table"?

        eureka!
        (insert Archimedes running naked through the streets with joy.... or how about not, your call)

        Thank you greatly.


        jcpunk
        all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)