in reply to Scope problem in closures with an eval statement
If you can in your case, you could use the non-string form of eval:
sub emphasizePrint { my $k = "!!\n"; return sub { my ($str) = @_; eval { print "$str$k" }; print STDERR "Error: $@" if ($@); } }
If that isn't applicable in your case I know no other way around than mentioning the variables in the closure once.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scope problem in closures with an eval statement
by ysth (Canon) on Apr 15, 2008 at 06:57 UTC |