in reply to Re: Persistent Variable
in thread Persistent Variable

It may not have been clear from my original post, but the subs themselves are in different package, that are being called by main, so they variables wouldn't be seen if I just declared them as globals.

Replies are listed 'Best First'.
Re: (3) Persistent Variable
by Adam (Vicar) on Jan 16, 2001 at 03:30 UTC
    Actually, that's what I meant when I said, "If you have them in a namespace other then main::, then you'll either want to use our (5.6+) or use vars($^V<5.6)." With out playing games with the import() method or Exporter, you can get to package globals by fully specifying the package name. ie:
    use strict; # I can't emphasize that enough! { package Common; use vars qw/ $Var1 @Var2 /; $Var1 = "some value"; @Var2 = ( 1, 2, 3); if( $^V =~ m/^5\.6/ ) { our $Var3 = "The 5.6 way to do the above"; } } # Now in main:: name space print $Common::Var1; print reverse @Common::Var2;