Seumas has asked for the wisdom of the Perl Monks concerning the following question:

I'm still new to object oriented perl and am having a very difficult time with one thing.

I have a main script and then I have a number of packages. Each package has a class and some methods.

At least two of these classes will be used by many (if not all) of the other packages. These two are called:
Creates an object containing all system config settings
Creates an object containing all the session/login info about the currently logged-in user.

The problem is that specific instances of both objects need to be accessed by multiple (if not all) other packages. That is, I don't want to do a 'use Login; use Config;' inside of *every* package that needs the config or login data.

If I have the following packages, I want them ALL to access the same instance of the login or config object, instead of each having it's own copy/instance - including the main script itself.

I'm not sure how to do this?

I've been looking through the Perl Cookbook as well as Merlyn's newer Object/References book and if they contain the answers to this, I didn't know it when I saw it.

Is my only solution to do one of the following or is there something more elegant?

1) Create an instance of the config and login objects in the main script. Then when I access any other packages or classes from the main script, have the first arguement (after the class/$self) be a reference to $Main::login so that each package could then be accessing the main instance of it? Such as $main::login->{_login}->{session_id}. And if I access a class from another class that itself is accessed from the main scripted (say, accesses and accesses, I would have pass to a reference to the reference of $Main::login or $Main::config . . .?


2) Something to do with prototyping?

Needless to say, I'm a bit lost right now. I've spent a few days trying to figure this one out and my little project is at an impasse until I do something (since, obviously, config and login objects are a bit essential!).