views:

231

answers:

1

My perl script is slow but works. I am considering throwing it out and building a true DB2 application with proper binds and such; however, in the meantime I want this to work as a place holder.

I looked at this documentation and it mentions:

$dbh->disconnect();

However I cannot use it because it throws this error.

Can't locate object method "disconnect" via package "dbh" (perhaps load "dbh"?) at ./ProgramTree.pl line 119.

I know my temporary application is leaking and growing because it is recursively opening database handles. Am I missing something fundamental?

+6  A: 

That error sounds an awful lot like the sigil is missing and you're running just dbh->disconnect();.


Look at what happens when an object doesn't have a method:

    [~] perl -e'my $dbh = bless {}, q/foo/; $dbh->disconnect();'
    Can't locate object method "disconnect" via package "foo" at -e line 1.

Compared to when you're calling that method on the bareword "dbh":

    [~] perl -e'dbh->disconnect();'
    Can't locate object method "disconnect" via package "dbh" (perhaps you forgot to load "dbh"?) at -e line 1.
Anonymous
Thank you... I feel like a dunce...
ojblass
Happens to all of us! Especially to me, actually... ;)
Marcus