in reply to Re^2: Where did $@ go?
in thread Where did $@ go?
As for your example, the core docs say that if eval completes without error, then $@ is guaranteed to be a null stringEven if that would be true, then
so you can write eval{...}; warn if $@;doesn't follow.
For the second, you also need $@ to be true if the eval fails. Which doesn't need to be the case.
The problem is end-of-scope effects. eval { } is a block. Leaving the block, whether due to reaching the end, entering a return, or because the code dies, triggers end of scope effects. Which may cause more code to be executed (think DESTROY blocks). Which may clear, or set $@.
This is a known, but hard problem to solve (as one doesn't want to lose information carried in $@). There will be improvements in 5.14, IIRC.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Where did $@ go?
by John M. Dlugosz (Monsignor) on Mar 21, 2011 at 12:06 UTC | |
by Corion (Patriarch) on Mar 21, 2011 at 12:11 UTC | |
by John M. Dlugosz (Monsignor) on Mar 21, 2011 at 12:18 UTC | |
by JavaFan (Canon) on Mar 21, 2011 at 13:31 UTC |