Perl Diver 2.31
Main Environment Variables Perl Default Values Perl Config - Summary Perl Config - Full Installed Modules List Directory uptime Docs

Module Documentation
Details and documentation about a specific module, including version and documentation (if available). Note that while links to perldoc.com and search.cpan.org are provided, the module may be part of a larger distribution. If you reach a File Not Found page on either site, please try the parent module.

Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode

Name Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode
Version 1.134
Located at /usr/share/perl5/vendor_perl
File /usr/share/perl5/vendor_perl/Perl/Critic/Policy/ControlStructures/ProhibitUnreachableCode.pm
Is Core No
Search CPAN for this module Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode
Documentation Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode
Module Details Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode


NAME

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


AFFILIATION

This Policy is part of the core Perl::Critic distribution.


DESCRIPTION

This policy prohibits code following a statement which unconditionally alters the program flow. This includes calls to exit, die, return, next, last and goto. Due to common usage, croak and confess from Carp are also included.

Code is reachable if any of the following conditions are true:


EXAMPLES

  # not ok
  exit;
  print "123\n";
  # ok
  exit if !$xyz;
  print "123\n";
  # not ok
  for ( 1 .. 10 ) {
      next;
      print 1;
  }
  # ok
  for ( 1 .. 10 ) {
      next if $_ == 5;
      print 1;
  }
  # not ok
  sub foo {
      my $bar = shift;
      return;
      print 1;
  }
  # ok
  sub foo {
      my $bar = shift;
      return if $bar->baz();
      print 1;
  }
  # not ok
  die;
  print "123\n";
  # ok
  die;
  LABEL: print "123\n";
  # not ok
  croak;
  do_something();
  # ok
  croak;
  sub do_something {}


CONFIGURATION

This Policy is not configurable except for the standard options.


SEE ALSO

Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls


AUTHOR

Peter Guzis <pguzis@cpan.org>


COPYRIGHT

Copyright (c) 2006-2011 Peter Guzis. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.

Perl Diver brought to you by ScriptSolutions.com © 1997- 2025