in reply to Re: BEGIN initialization and memory
in thread BEGIN initialization and memory

So the memory for the BEGIN code itself is released to perl's memory pools then?

Thanks.

I started playing with some of this.

#!/usr/bin/perl -wl package A; sub AUTOLOAD { print join ":", $AUTOLOAD, @_; } package main; BEGIN { my $a = bless {}, 'A'; print 'In BEGIN'; local(*my_sub) = bless sub { print "my_sub called"; }, 'A'; my_sub(); *undefed_sub = bless sub { print "undefed_sub called"; }, 'A'; undefed_sub(); #undef &undefed_sub; # don't work, destroyed after prints undef *undefed_sub; } print 'Runtime'; eval { my_sub() }; print "my_sub gone" if $@ =~ /^Undefined subroutine/; eval { undefed_sub() }; print "undefed_sub gone" if $@ =~ /^Undefined subroutine/; __END__ In BEGIN my_sub called undefed_sub called A::DESTROY:A=HASH(0x8100c18) A::DESTROY:A=CODE(0x8100b7c) A::DESTROY:A=CODE(0x8100ad4) Runtime my_sub gone undefed_sub gone