Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Wednesday June 28, 2006
09:31 AM

DESTROY redefined?

[ #30077 ]

Today's annoyance was writing this bit of code for tearing down my test database:

no warnings 'redefine';
*DESTROY = sub {
    my $self = shift;
    my $dbh  = $self->dbh;
    # boring stuff
    $dbh->disconnect;
};

That's in my _initialize method for the constructor. That eliminated my "subroutine DESTROY redefined at ..." warning, but for the life of me, I can't figure out how this method was getting redefined. This seems to to be a common problem with database related modules, but I'm only seeing the error reports, not the resolution. I hate hitting a problem that should be simple yet I nonetheless get stumped on. Brute forcing a solution makes me feel icky.

Of course, the garbage collection bugs also mean that the stored database handle might be garbage collected when I get to this point. I'll have to fix that, too, if it hits me (usually done with an annoying lexical variable hanging around in my otherwise clean code). Has this ever been fixed?

Update: How embarrassing. I remembered how to solve this:

use Sub::Identify ':all';
main::diag(stash_name(\&DESTROY));

Guess what? That DESTROY came from my own Class::BuildMethods. Of course, I documented that it exports a DESTROY unless specifically told not to, so it's my own fault :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.