reproducible GLOB problem, Was: 'how to convert shell captures into anyevent style?'

Marc Lehmann schmorp at schmorp.de
Thu Apr 5 06:26:13 CEST 2012


On Wed, Apr 04, 2012 at 11:23:18PM -0400, Fulko Hew <fulko.hew at gmail.com> wrote:
> I'm sorry if its confusing, I thought I made it as clear and as short as
> possible.

The problem si the formatting. You have very
long
lines and then very short lines after that. That means that
reading
your e-mail is really hard because the formatting makes it hard to pick
up
important details.

^ just like this.

> 1/ Attempting to install a DIE catcher using $SIG{__DIE__}=
> causes the Perl to generate the GLOB error I was originally questioning,
> preventing the app from even starting [regardless of why I am trying to
> catch the DIE and what I will do with it].

Perl always generates the GLOB error. As I explained in my first reply,
if you don't like to see it, don't print it, or don't install a __DIE__
handler, or fix your die handler to do what you want, as I have explained
in my previous reply.

Here is an example (taken from the deliantra client) that *probably* is near
to what you want to do. The 0..999 loop should be replaced by a while loop
that only ends when the call stack ends:

   $SIG{__DIE__} = sub {
      return if $^S; # quick reject

      # return if there are any eval contexts in the call stack
      for my $i (0..999) {
         my ($sub, $is_require) = (caller $i)[3, 7]
            or last;
         return if $sub eq "(eval)" && !$is_require;
      }

      ... do your stuff here
   }

But, let me repeat: __DIE__ is not for the faint of heart. If you don't
understand what it does (and that is true for you), then most likely it is
the wrong solution to your problem.

> 2/ Using AnyEvent->signal() silently fails to catch __WARN__.

__WARN__ is not a signal, but a perl-internal hook, please refer to the
perlvar manpage for details. (As I explained in my previous mail as
well...).

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at schmorp.de
      -=====/_/_//_/\_,_/ /_/\_\



More information about the anyevent mailing list