![]() |
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 |
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.