On Sunday 06 May 2007 04:29:48 am A. Pagaltzis wrote: > * Evan Carroll <[EMAIL PROTECTED]> [2007-05-06 10:55]: > > With that said, the patch provided has no drawbacks, and even > > if you only use the most minimal functionality of M::DBI, with > > the current code, you don't have a connection until the first > > ->dbh is called, which is no bueno. (work that is better > > handled at compile-time) > > That is precisely the patch’s drawback. Connecting lazily rather > than eagerly is a feature. > > However, that’s not hard to correct, although the patch would be > larger: rather than squirreling away a connection in `new`, > squirrel away a reference to an undef scalar. Then you can assign > the handle to that scalar, and it will be shared among everyone > who kept a copy of the same reference.
There's also Scalar::Defer:
my $connection = defer { DBI->connect ... } ;
# not connected yet;
$connection->prepare(...); # bang! connected.
--
package JAPH;use Catalyst qw/-Debug/;($;=JAPH)->config(name => do {
$,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //,
";$;"]->[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;->setup;
pgp13y3ONk5Tc.pgp
Description: PGP signature
_______________________________________________ List: [email protected] Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
