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. :)