in reply to what is a propper way to make a chunk of data accessible to all my packages for retrieval and modification ?

Brief answer (I'm heading to bed - really, I am): use a singleton object to hold your global configuration information. You can use new anywhere you want to, but after the first new (which creates the object), subsequent news simply return a reference to the singleton object.


DWIM is Perl's answer to Gödel
  • Comment on Re: what is a propper way to make a chunk of data accessible to all my packages for retrieval and modification ?

Replies are listed 'Best First'.
Re^2: what is a propper way to make a chunk of data accessible to all my packages for retrieval and modification ?
by Aristotle (Chancellor) on Feb 20, 2006 at 03:49 UTC

    How is that any different from global variables? The singleton’s class name is a global identifier.

    (For more arguments other than those applicable to this particular use case, see Singleton Considered Stupid.)

    Makeshifts last the longest.

      What i read here in that link.. ominous.. Yeah im getting the feeling that i might as well use global variables then singleton objects.

      so, i still have these "master hashes" that i'd like to have my whole program access, want to add new modules as time goes by and no matter where the code is, i want to know that %::Garage will hold all the cars- and i have to do that by declaring our %Garage in main.

      am i going to coding hell?

      Please keep in mind im a poop virgin.

      i'm feeling like i've really missed something here with scoping and protecting symbol tables and even why- im thinking maybe i need to .. take a vacation. or play with static electricity close to the box fan.

      where can i read about ways around poop? about protecting the symbol table, why... any specific suggestions?

        I’d suggest writing configuration class and having the constructors of all your application classes take an instance of it.

        It depends on what you need to do with the data, though. Not all globals are evil.

        Makeshifts last the longest.