Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

•Re: Perl Singletons

by merlyn (Sage)
on Jul 19, 2002 at 19:52 UTC ( #183419=note: print w/ replies, xml ) Need Help??


in reply to Perl Singletons

There's no point in even returning an instance. Just return the package name:

package DBconnector; my $dbh; sub new { return __PACKAGE__ } sub connect { my $pointless = shift; $dbh ||= DBI->connect($@); }
and so on.

-- Randal L. Schwartz, Perl hacker


Comment on •Re: Perl Singletons
Download Code
Replies are listed 'Best First'.
Re^2: Perl Singletons
by Aristotle (Chancellor) on Jul 19, 2002 at 20:44 UTC
    $dbh ||= DBI->connect($@);

    You probably mean @_ there.. at least I can't see an eval anywhere *grin*

    ++ tho. :)

    Makeshifts last the longest.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2015-07-29 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls