Hello,
I am little confused, so I hope this makes sense. I tried to find a thread to answer this already, but didn't have any luck...
I am running a require on a variable name within an eval. Here is a simplified version:
eval qq{
$file = 'foo.pl'; # foo has errors in it
require "$file";
}
dienice("that code is busted because: $@") if $@;
but that doesn't work for me. The dienice never gets triggered. Now here's my confusion:
When a require fails because the code being slurped-in has a missing ; or some other error its supposed to exit out and print $@, right?
But in this case that exit is trapped by the eval. Then the eval evaluates to false because the return wasn't 1, because the code failed in the require right?
Since the eval failed, I would expect the $@ to persist and be detected and printed by the dienice(), therefore telling me what the error was in foo.
I tried wrapping the require in an eval, but then I couldn't double quote the variable and there was a syntax error. I also tried putting the dienice inside the eval, but it still didn't work. Can someone set me straight here?
Thanks,
Alex
p.s.- this is my fourth question since finding the monks, and this place is so unbelievably helpful I'm stunned. I've been just reading random threads for a couple weeks now and am learning TONS. Just a quick thanks to everyone. :)
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.