Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: special $dbh can't error?

by Anonymous Monk
on Oct 03, 2008 at 10:43 UTC ( [id://715182]=note: print w/replies, xml ) Need Help??


in reply to special $dbh can't error?

Can anyone explain me what sets my expections out of sync with reality?
Probably because can isn't what you think it is. Try UNIVERSAL::can()
use DBI; my $dbh=DBI->connect("dbi:SQLite:dbname=dbfile"); warn $dbh; print "can error: ", $dbh->can("error"),"\n"; print "UNIVERSAL::can((", UNIVERSAL::can($dbh,'error'),"\n"; eval {print $dbh->error('eeep');};warn $@ if $@; bless $dbh, "My::Special::DBI::db"; warn $dbh; print "can error: ", $dbh->can("error"),"\n"; print "UNIVERSAL::can((", UNIVERSAL::can($dbh,'error'),"\n"; eval {print $dbh->error('eeep');};warn $@ if $@; print "\n-----\n\n"; package My::Special::DBI::db; use base qw(DBI::db); sub error { my $dbh=shift; return $dbh->errstr(); } __END__ DBI::db=HASH(0x19b7f1c) at dbi.dbd.error.subclass.pl line 3. can error: UNIVERSAL::can(( Can't locate object method "error" via package "DBI::db" at dbi.dbd.er +ror.subclass.pl line 6. My::Special::DBI::db=HASH(0x19b7f1c) at dbi.dbd.error.subclass.pl line + 8. can error: UNIVERSAL::can((CODE(0x19978e4) -----

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://715182]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-25 14:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found