/usr/local/perl/lib/site_perl/5.8.5/Perl/Critic/Policy/ControlStructures/ProhibitUnreachableCode.pm |
Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode
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
the Carp manpage are also included.
Code is reachable if any of the following conditions are true:
&&
, ||
, and
, or or
.goto
)
# 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 {}
the Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls manpage
Peter Guzis <pguzis@cpan.org>
Copyright (c) 2006 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.
/usr/local/perl/lib/site_perl/5.8.5/Perl/Critic/Policy/ControlStructures/ProhibitUnreachableCode.pm |