Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: using modules already 'used'

by ariels (Curate)
on May 09, 2002 at 12:22 UTC ( [id://165351]=note: print w/replies, xml ) Need Help??


in reply to using modules already 'used'

What you want is what the heavy-OO people call a "singleton". You could write one yourself (WARNING! Untested code!):

package CGI::Single; our @ISA; @ISA = ('CGI'); my $instance; sub instance { defined $instance or $instance = new CGI; $instance; } 1;
Now, say "$q = CGI::Single->instance" instead of "$q = new CGI".

Or, CPAN has Class::Singleton, which should let you just say (again, untested!), mixin-style,

package CGI::Single; our @ISA; @ISA = qw(CGI Class::Singleton); 1;
with the same use as before.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://165351]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-03-29 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found