Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^3: exit this way

by Anonymous Monk
on Sep 01, 2015 at 05:54 UTC ( [id://1140611]=note: print w/replies, xml ) Need Help??


in reply to Re^2: exit this way
in thread exit this way

it would be nice to have a "code not reachable" message

There isn't such a check for post-exit(), but Perl::Critic definitely has a rule for pre-use strict;. I guess one could write a rule that ignored subroutines...

Hmm,

Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode - Don't write code after an unconditional die, exit, or next.

Perl::Critic::Policy::Modules::ProhibitExcessMainComplexity - Minimize complexity in code that is outside of subroutines.

Replies are listed 'Best First'.
Re^4: exit this way
by 1nickt (Canon) on Sep 01, 2015 at 07:11 UTC

    Oof. Updated.

    I ran a little test script but my .perlcriticrc had got borked somehow so perlcritic ran with -5 (why is that the default, anyway?), and the rule has a severity of 4. I didn't notice anything wrong because "Code before strictures enabled" has a severity of 5, so it did throw an error. Thanks for the correction. (When I first went to answer the question I thought I remembered there was a rule!)

    #!/usr/bin/perl use warnings; my $foo = 'bar'; use strict; exit(0); my $baz = 'quux';
    $ perlcritic 1140661.pl Code before strictures are enabled at line 3, column 1. See page 429 +of PBP. (Severity: 5)
    $ perlcritic -4 1140661.pl Code before strictures are enabled at line 3, column 1. See page 429 +of PBP. (Severity: 5) Unreachable code at line 9, column 1. Consider removing it. (Severit +y: 4) $

    The way forward always starts with a minimal test.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-28 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found