in reply to Re^4: Does there exist a CPAN module for lazily initialized variables?
in thread Does there exist a CPAN module for lazily initialized variables?
No, the difference here is that you make this call $dbh->connect_cached() so that instead of just storing your object - you revivify it automatically as needed. I think of this as important for something that will be long running - I'd just go with a plain stored value otherwise.
sub main::dbh { # for daemons and long running code - reconnect as needed DBI->connect_cached( ... ) } sub main::dbh { # initialize the connection or re-use. $::DBH ||= DBI->connect( ... ) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Does there exist a CPAN module for lazily initialized variables?
by jryan (Vicar) on Jul 14, 2004 at 20:45 UTC | |
by diotalevi (Canon) on Jul 14, 2004 at 20:53 UTC | |
by jryan (Vicar) on Jul 14, 2004 at 21:00 UTC |