in reply to Package variables

NEVERMIND. I figured it out already. I was going to check the vars pragma manpage *before* I posted this question, but it slipped my mind.

For the record, in case anyone else wants to know:

package Foo; use strict; use vars qw/$BAR/; $BAR = "baz"; package main; print $Foo::BAR;

So, use vars declares 'global' variables (global to the package) that aren't private like my().

Replies are listed 'Best First'.
RE: Re: Package variables
by chromatic (Archbishop) on Apr 25, 2000 at 18:35 UTC
    You can also initially declare them in a package:
    use strict; # just to prove my point package hidden; $hidden::foo = "This is the first time I've been used."; package main; print $hidden::foo;
RE: Re: Package variables
by jbert (Priest) on Apr 25, 2000 at 18:09 UTC
    Close enough. 'use vars' just selectively excludes some variables from the 'use strict'.

    So you can do the same by omitting 'use strict'.

    Of course, the way in which you did it was much better...