Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   DBI and symbol table (http://www.velocityreviews.com/forums/t893822-dbi-and-symbol-table.html)

Matija Papec 08-20-2005 01:12 PM

DBI and symbol table
 

I would like to temper calls to DBI so that caller gets DBIfoo object if
real DBI method failed for some reason. The code below should imho do just
that but no luck so far. What is wrong with it?


=======
use Data::Dumper;
use DBI;
$dbh = DBI->connect;



package DBIfoo;
use Data::Dumper;

my $DBI_connect;
BEGIN {
# $DBI_connect = $DBI::{connect};
# $DBI::{connect} = \&connect;
$DBI_connect = *DBI::connect;
*DBI::connect = \&connect;
}

sub connect {
# $DBI_connect = sub { print "@_ ", __PACKAGE__ };
return &$DBI_connect || (bless {}, __PACKAGE__);
}

1;



--
Matija

Matija Papec 08-20-2005 01:19 PM

Re: DBI and symbol table
 
>BEGIN {
># $DBI_connect = $DBI::{connect};
># $DBI::{connect} = \&connect;
> $DBI_connect = *DBI::connect;

^
$DBI_connect = &DBI::connect;
^

to answer my own question. :)



--
Matija


All times are GMT. The time now is 04:28 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57