in reply to single instance shared with module
Now both main and B can call the same instance of A by just:package A; my $obj = undef; sub new { my $class = shift; unless (ref $obj eq 'A') { # initilize object... $obj = bless \%self, $class; } return $obj; }
... in theory :) This is UNTESTED code and someone is allowed to thwack me in the back of the head soundly if I am missing something here.use A; my $obj = new A();
--
perl: code of the samurai
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: single instance shared with module
by sauoq (Abbot) on Sep 16, 2002 at 21:12 UTC | |
|
Re^2: single instance shared with module
by adrianh (Chancellor) on Sep 16, 2002 at 22:52 UTC | |
|
Re^2: single instance shared with module
by Aristotle (Chancellor) on Sep 17, 2002 at 10:25 UTC | |
|
Re^2: single instance shared with module
by adrianh (Chancellor) on Sep 17, 2002 at 21:28 UTC |