in reply to Why isn't a fatal error trappable?
It is trappable:
c:\test>perl -E"chop for 'fred'; print 'here' " Modification of a read-only value attempted at -e line 1. c:\test>perl -E"eval{ chop; } for 'fred'; print 'here' " here
The only circumstance I'm aware of that it isn't, is if you supply a constant directly to a mutator:
c:\test>perl -E"chop 'fred'; print 'here' " Can't modify constant item in chop at -e line 1, near "'fred';" Execution of -e aborted due to compilation errors. c:\test>perl -E"eval{ chop 'fred' }; print 'here' " Can't modify constant item in chop at -e line 1, near "'fred' }" Execution of -e aborted due to compilation errors.
And that, I've always assumed, is because it is detected at compile time rather than runtime.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why isn't a fatal error trappable?
by ikegami (Patriarch) on Nov 16, 2010 at 18:22 UTC |