Skip to content

Instantly share code, notes, and snippets.

@wakaba
Created December 9, 2012 12:40
Show Gist options
  • Save wakaba/4244683 to your computer and use it in GitHub Desktop.
Save wakaba/4244683 to your computer and use it in GitHub Desktop.
{
package test::fuga;
sub DESTROY {
warn "fuga->DESTROY called";
}
}
my $fuga = bless {}, 'test::fuga';
my @hoge;
Internals::SvREADONLY (@hoge, 1);
eval {
push @hoge, $fuga;
};
warn 0+@hoge;
undef $fuga;
warn "End of program";
@wakaba
Copy link
Author

wakaba commented Dec 9, 2012

$ perl b.pl
0 at b.pl line 15.
End of program at b.pl line 18.
fuga->DESTROY called at b.pl line 4 during global destruction.

(Perl 5.10.1 / 5.16.2)

@wakaba
Copy link
Author

wakaba commented Dec 9, 2012

By removing the line Internals::SvREADONLY (@hoge, 1);, it got:

$ perl b.pl
1 at b.pl line 15.
End of program at b.pl line 18.
fuga->DESTROY called at b.pl line 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment