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:umper;
use DBI;
$dbh = DBI->connect;
package DBIfoo;
use Data:umper;
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;
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:umper;
use DBI;
$dbh = DBI->connect;
package DBIfoo;
use Data:umper;
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;