in reply to Dynamically Creating a Code reference
First, make sure you do
use strict; use warnings;
in your code if you aren't already.
To be honest, I have not looked into this in detail, but have a look at the $code =<<"END" part. The double quotes will make your string be interpolated, which mean while assigning to $code your variables $dfv etc will be expanded, and may well be undefined. Thus eval might see only my = shift;, which doesn't compile. eval fails and sets $@ aka $EVAL_ERROR, which you should check for.
Use single quotes around END, or escape everything that might be interpolated.
Also, you might consider moving the semicolon after the END up, that is:
$code = <<'END';
I hope I got it somewhat right, and it helps a bit.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamically Creating a Code reference
by Herkum (Parson) on Jun 16, 2006 at 12:25 UTC |