in reply to Persistant variable/data/object?

Yes. You can do something like:

package MyConfiguration; our @EXPORT = "get_config"; use base "Exporter"; our $CONFIG = load_vars(); sub get_config() { $CONFIG } sub load_vars { ... } 1;

Then you just use MyConfiguration; everywhere you need to access the configuration and call get_config whenever you need it.

Update: liz was kind enough to point out that "use" isn't spelled "base" ;-)

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

Replies are listed 'Best First'.
Re: Re: Persistant variable/data/object?
by TomDLux (Vicar) on Jan 08, 2004 at 22:46 UTC

    The Object-Oriented gang call this a singleton, but Antirice demonstrates you don't need an object to use the pattern.

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

Re: Re: Persistant variable/data/object?
by asiufy (Monk) on Jan 08, 2004 at 21:14 UTC
    Thanks!

    I've done this a zillion times in Java code, but I just couldn't think of a Perl way to do the same thing :) I still need a better grip of the 'use base' thing, as well as the whole @ISA mechanism. Any pointers to good tutorials?

    ++