in reply to Re: Scope problem in closures with an eval statement
in thread Scope problem in closures with an eval statement

That's really a bad idea in the general case, because it won't work if $k has a string terminator in it:
sub emphasizePrint { my $k = qq{"!!\n}; return sub { my ($str) = @_; eval (qq{print "$str$k"}); print STDERR "Error: $@" if ($@); } } __END__ Error: Can't find string terminator '"' anywhere before EOF at (eval 1 +) line 2.

In the general case this opens lots of holes, which can be a security risk.

I think that citromatik deliberately interpolated the variables at eval time, not prior to evaling the string.