in reply to Proper way to create 'globals'

If your TestSuite is a singleton (as it sounds like), you can make a package variable ($TestSuite::ts) that contains the one TestSuite that's been instantiated, and then everybody can have at it as they like.

If you plan to have more than one TestSuite, have it hand itself to its sub-objects at their creation.

$ts->make_a_blob(); $ts->{blob}->{your_lord_and_master} = $ts; weaken $ts->{blob}->{your_lord_and_master};

Note the importance of using weaken from Scalar::Util to create a weak reference. Without that, the circular references we just created will keep the objects from being destroyed properly when it's time to collect garbage.

Then Blob::print_stuff() can look at $self->{your_lord_and_master}->{info} and more.

Replies are listed 'Best First'.
Re^2: Proper way to create 'globals'
by zaven (Sexton) on Feb 07, 2007 at 22:51 UTC
    Thanks folks, I think the package variable is probably the correct answer here :-)