Skip to content

Instantly share code, notes, and snippets.

@pmakholm
Created May 22, 2009 10:51
Show Gist options
  • Save pmakholm/116060 to your computer and use it in GitHub Desktop.
Save pmakholm/116060 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
#
# An evil form of perl DESTROY-method
use strict;
use warnings;
{
package Evil;
our @DESTROYED;
sub new {
my $class = shift;
return bless {}, $class;
}
sub DESTROY {
warn "Destroy $_[0]";
push @DESTROYED, $_[0];
}
}
my $evilobj = Evil->new();
$evilobj = undef;
shift @Evil::DESTROYED;
shift @Evil::DESTROYED;
shift @Evil::DESTROYED;
shift @Evil::DESTROYED;
shift @Evil::DESTROYED;
shift @Evil::DESTROYED;
shift @Evil::DESTROYED;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment