in reply to Subroutine redefined error that I can't figure out
Basically, subroutine names are global. Perl does not have locally nested subroutines.
One possible way around it is to localize your changes to the symbol table:
local *evalsub; eval $code; evalsub();
Another way is to avoid using named subroutines and use code references:
my $code = 'sub { print "evalsub" }'; my $coderef = eval $code; # Call our code $coderef->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Subroutine redefined error that I can't figure out
by nickm (Novice) on Apr 11, 2008 at 14:12 UTC |