in reply to store a warning in a variable

my $warning; $SIG {__WARN__} = sub {$warning = @_ == 1 ? shift : join " ", @_};

Replies are listed 'Best First'.
Re^2: store a warning in a variable
by 7stud (Deacon) on Nov 09, 2010 at 19:51 UTC
    How can the length of @_ be anything other than 1?
      You are right. It even becomes much simpler:
      my $warning; $SIG{__WARN__} = sub {$warning = shift};
        You are right.

        No, it wasn't a rhetorical question. I thought you were going to have an explanation for me.

        Thanks :)