in reply to Scope problem in closures with an eval statement
my $print = emphasizePrint(); $print->("Hello World"); ## Prints "Hello World!!" sub emphasizePrint { my $k = "!!\n"; return sub { my ($str) = @_; eval (qq{print "$str$k"}); print STDERR "Error: $@" if ($@); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scope problem in closures with an eval statement
by moritz (Cardinal) on Apr 15, 2008 at 08:55 UTC |