my $module = do {
open(my $fh, '<', 'Module.pm')
or die("Unable to read Module.pm: $!\n");
local $/;
<$fh>
};
eval $module or warn $@;
$module =~ s/^for;$/#for;/m;
eval $module or warn $@;
####
use strict;
use warnings;
package Module;
sub one { }
for;
sub two { }
1;
####
Subroutine one redefined at (eval 2) line 6.
####
use strict;
use warnings;
package Module;
END { print("END1\n"); }
for;
END { print("END2\n"); }
1;
####
END2
END1
END1
####
use strict;
use warnings;
package Module;
BEGIN { print("BEGIN1\n"); }
for;
BEGIN { print("BEGIN2\n"); }
1;
####
BEGIN1
####
BEGIN1
BEGIN2
####
use strict;
use warnings;
package Module;
{
package Obj;
sub new { print "Creating\n"; bless({}, shift) }
sub DESTROY { print "Destroying\n"; }
}
our $o;
BEGIN { $o = Obj->new(); }
for;
1;
####
Creating
####
Subroutine new redefined at (eval 2) line 8.
Subroutine DESTROY redefined at (eval 2) line 9.
Creating
Destroying
Destroying