in reply to Why isn't a fatal error trappable?

What do you mean by not trapping?
$ perl -e 'eval {undef=1;1} or die "Died: $@"' Died: Modification of a read-only value attempted at -e line 1.

Replies are listed 'Best First'.
Re^2: Why isn't a fatal error trappable?
by perl-diddler (Chaplain) on Nov 16, 2010 at 11:47 UTC
    I mean I have an error handler that normally traps errors, but it's not catching this one....

    (ie...using SIG{DIE} & SIG{WARN}...)

    For that matter, in this case, how do I test if a value is writable before writing to it?

    In this case the error is the result of attempting to assign to a variable that is declared as the result of being "aliased" to a 'stack' variable. I'm not sure how it would ever end up being 'readonly' -- undefined, MAYBE, but readonly??

    don't see how off hand...

      I can trap the error with a handler, too:
      $ perl -e '$SIG{__DIE__} = sub {die "Handled: @_"};undef=1' Handled: Modification of a read-only value attempted at -e line 1.

      Should that be __DIE__ and __WARN__ ?

      -derby
      A reply falls below the community's threshold of quality. You may see it by logging in.