DBI and symbol table

Discussion in 'Perl Misc' started by Matija Papec, Aug 20, 2005.

  1. Matija Papec

    Matija Papec Guest

    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, Aug 20, 2005
    #1
    1. Advertising

  2. Matija Papec

    Matija Papec Guest

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

    ^
    $DBI_connect = &DBI::connect;
    ^

    to answer my own question. :)



    --
    Matija
    Matija Papec, Aug 20, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ulloa
    Replies:
    1
    Views:
    523
    Juha Laiho
    Jul 22, 2004
  2. baumann@pan
    Replies:
    1
    Views:
    742
    Richard Bos
    Apr 15, 2005
  3. Jerome Hauss
    Replies:
    0
    Views:
    166
    Jerome Hauss
    Oct 13, 2004
  4. Asby

    Mason, DBI, and DBI::Pg

    Asby, Jul 24, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    173
  5. Tim Haynes
    Replies:
    3
    Views:
    140
    Ron Reidy
    Sep 13, 2003
Loading...

Share This Page