The return value of an eval() is simply the value of the last
expression evaluated in the eval, or undef if there is an error. Is there something you
want to do with an eval that you might want to explain?
(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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.