DBI and symbol table

M

Matija Papec

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;
 
M

Matija Papec

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

to answer my own question. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top