[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

$^S and eval



I have a long-standing problem in detecting when code is being eval'ed and
when not.

In gimp-perl, I try to catch die's to be able to display them in a message
box, not on standard error. To do this, I add a __DIE__-Handler:

   $SIG{__DIE__} = sub {
      unless ($^S || !defined $^S || $in_quit) {
         die_msg $_[0];
         initialized() ? &quiet_die : exit quiet_main();
      } else {
         die $_[0];
      }
   };

The logic is: if "!$^S && defined $^S", then we are in an eval, and just
re-throw the error, otherwise display it.

Unfortunately, during eval parsing, $^S has the value "undef", which is
indistinguishable from the value "undef" it has when parsing a module.

So errors during module parsing cannot be detected, or, put otherwise,
either I spoil eval's (which is obviously unacceptable), or I miss most of
the syntax errors in scripts.

So... this is not a bug (at least it works exactly as documented), but
I am unsure what the reasoning behind this is?  The difference between
eval parsing and eval running seems to be very minor, compared to the
difference between parsing source and parsing an eval.

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@opengroup.org |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |


[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]