in reply to Re: Prevent import of subroutines from eval
in thread Prevent import of subroutines from eval
... use different packages in the evals. Just prepend ...
++Ooo, that works very nicely!
c:\@Work\Perl>perl -wMstrict -le "sub foo { print __PACKAGE__, ' foo'; } ;; my $e_str = q{sub foo { print __PACKAGE__, ' foo'; }; foo(); }; ;; for my $n (1 .. 3) { my $p = qq{package Bar$n; }; eval $p . $e_str; } ;; foo(); Bar1::foo(); Bar2::foo(); Bar3::foo(); " Bar1 foo Bar2 foo Bar3 foo main foo Bar1 foo Bar2 foo Bar3 foo
|
|---|