in reply to Eval/package question
You already got the answer from GrandFather, but here's another way to see what's happening:
That way you'll see exactly what eval receives as an argument.print("$items{3}{Value} = 2;"); eval("$items{3}{Value} = 2;");
Why are you using eval in the first place? String eval means the code isn't compiled until the very last moment, so if you introduce some mistake like a syntax error, you wouldn't get notified until you execute the bit of code that contains the eval (which might not be everytime). If you're trying to catch errors, using a block eval (eval { $value = 2; }) lets perl compile the code rightaway, but only execute the section separately
Edit: corrected my code tags thanks to choroba's sharp vision :P
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Eval/package question
by Ratazong (Monsignor) on Jan 21, 2020 at 11:33 UTC | |
by haukex (Archbishop) on Jan 21, 2020 at 19:05 UTC | |
by shmem (Chancellor) on Jan 21, 2020 at 14:38 UTC | |
by Anonymous Monk on Jan 21, 2020 at 16:26 UTC | |
by jcb (Parson) on Jan 22, 2020 at 00:29 UTC |
In Section
Seekers of Perl Wisdom