Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Disabling runtime warnings in dynamic scope? (no warnings 'exiting'; use warnings 'exiting';

by beech (Parson)
on Apr 25, 2018 at 23:05 UTC ( #1213560=note: print w/replies, xml ) Need Help??


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 (Cardinal) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1213560]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2021-04-20 00:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?