in reply to eval output
(update) Here's a simple example that should help you with the idea: perl -le "print eval(print 1+1)" produces:
2 <-- printed within the eval() 1 <-- printed outside the eval()
(further update)When I have a question like this, I just try it: perl -le "$i=5;print $i,eval('$i++;print $i;');print $i" produces:
6 <-- printed outside the eval(), but AFTER it has run so $i has +been incremented 61 <-- 6 printed within the eval(), 1 printed outside 6 <-- printed in the next statement outside the eval()
Conclusion: eval() operates within the context of the host program.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: eval output
by thealienz1 (Pilgrim) on Nov 10, 2000 at 20:57 UTC | |
by Fastolfe (Vicar) on Nov 10, 2000 at 23:24 UTC |