in reply to Re^4: standard perl module and BEGIN block.
in thread standard perl module and BEGIN block.

I'm just curious here, but your looking for something that would look like...

package Some::Package; use vars qw/test/; sub inHere { our $test; }

If so I think that would be far more intuitive than the current setup. After a year of perl I still have no concept of our.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^6: standard perl module and BEGIN block.
by BrowserUk (Patriarch) on Aug 17, 2004 at 10:55 UTC

    Yes. And in this code:

    package Some:Module; use vars q/test/; ## Here "Global symbol "$test" requires explicit package name". $test = 1; sub inHere { our $test; # ok. our $tset; # typos/thinkos causes errors. my $test; # my variable "$test" overrides variable with the same name at differe +nt scope... } 1; Some::Other::Module; sub inThis { our $test; ## is an error. }

    If it is possible to get this behaviour, changing use vars; to work this way would probably cause backward compatibility issues, so maybe use globals qw/$var @var %var/; would make more sense.

    That said, maybe something like $var : global = 1; would be more in keeping with the latest trends and prehaps more compatible with P6.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon