http://qs321.pair.com?node_id=1213560


in reply to Disabling runtime warnings in dynamic scope?

Hi

Find the right scope and tickle ${^WARNING_BITS}?

$ perl -l #!/usr/bin/perl -- use strict; use warnings; use diagnostics; sub switch { no warnings 'exiting'; while (@_) { my ($case, $action) = splice @_,0,2; return $action->($case) if $_ ~~ $case; } } no warnings 'exiting'; switch [1,2,3] => sub { print "bla" ; next}, 3 => sub { print "bla2" } for (3); use warnings 'exiting'; switch [1,2,3] => sub { print "bla" ; next}, 3 => sub { print "bla2" } for (3); use warnings 'exiting'; switch [1,2,3] => sub { no warnings 'exiting'; print "bla" ; next}, 3 => sub { no warnings 'exiting'; print "bla2" } for (3); __END__ bla bla2 bla Exiting subroutine via next at - line 23 (#1) (W exiting) You are exiting a subroutine by unconventional means, +such as a goto, or a loop control statement. bla2 bla bla2
  • Comment on Re: Disabling runtime warnings in dynamic scope? (no warnings 'exiting'; use warnings 'exiting';
  • Download Code

Replies are listed 'Best First'.
Re^2: Disabling runtime warnings in dynamic scope? (no warnings 'exiting'; use warnings 'exiting';
by LanX (Saint) on Apr 25, 2018 at 23:13 UTC
        > Scope::Context

        Thanks, interesting! :)

        Seems to be based on Scope::Upper and does loads of black magic. (And might be useful to implement lisp style macros)

        But only on upper contexts. The subs in questions are "lower" contexts

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Wikisyntax for the Monastery

        I'm pretty sure PadWalker can't access global special vars inside a foreign sub.

        And manipulating the warn handler looks cleaner now (though I have to check caller(2) too)

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Wikisyntax for the Monastery