perl::critic::policy::controlstructures::prohibitcascadingifelse(3) [centos man page]
Perl::Critic::Policy::ControlStructures::ProhibitCascadiUserEContributed Perl DPerl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse(3)NAME
Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse - Don't write long "if-elsif-elsif-elsif-elsif...else" chains.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Long "if-elsif" chains are hard to digest, especially if they are longer than a single page or screen. If testing for equality, use a hash
lookup instead. If you're using perl 5.10 or later, use "given"/"when".
if ($condition1) { #ok
$foo = 1;
}
elsif ($condition2) { #ok
$foo = 2;
}
elsif ($condition3) { #ok
$foo = 3;
}
elsif ($condition4) { #too many!
$foo = 4;
}
else { #ok
$foo = $default;
}
CONFIGURATION
This policy can be configured with a maximum number of "elsif" alternatives to allow. The default is 2. This can be specified via a
"max_elsif" item in the .perlcriticrc file:
[ControlStructures::ProhibitCascadingIfElse]
max_elsif = 3
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. 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 v5.16.3 2014-06-09 Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse(3)
Check Out this Related Man Page
Perl::Critic::Policy::ControlStructures::ProhibitDeepNesUser)Contributed Perl DocumenPerl::Critic::Policy::ControlStructures::ProhibitDeepNests(3)NAME
Perl::Critic::Policy::ControlStructures::ProhibitDeepNests - Don't write deeply nested loops and conditionals.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Deeply nested code is often hard to understand and may be a sign that it needs to be refactored. There are several good books on how to
refactor code. I like Martin Fowler's "Refactoring: Improving The Design of Existing Code".
CONFIGURATION
The maximum number of nested control structures can be configured via a value for "max_nests" in a .perlcriticrc file. Each for-loop, if-
else, while, and until block is counted as one nest. Postfix forms of these constructs are not counted. The default maximum is 5.
Customization in a .perlcriticrc file looks like this:
[ControlStructures::ProhibitDeepNests]
max_nests = 3
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. 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 v5.16.3 2014-06-09 Perl::Critic::Policy::ControlStructures::ProhibitDeepNests(3)
I do not know perl but need to know what the following conditional statement says. Can someone help ?
if (/ \S+@\S+\.\S+ accepted $| \S+\/\S+ accepted $/) {
next;
}
elsif (/ (\S+)\.\S+\.\S+\.\S+ \S+ \S+ \S+ \S+ \S+ (\S+)\.\S+\.(\S+)\.\S+ \S+ User (\S+) accepted... (2 Replies)
Hi all,
I check in awk only have if ...else ..
if (condition) then-body
how about
if (condition1) {
command1
}
else if (condition2) {
command2
}
else (condition3){
command3
} (1 Reply)
All,
I'm having a problem w/this function. Specifically, I want to call another function (get_stats) when the process in the else completes (the initial if and the elsif seem to work fine). But what's happening is the get_stats function call is running after the else runs only once, NOT when it... (8 Replies)
I have having problems with an IF statement in my perl script:
if ($model eq "N\\A") {}
elsif ($kernel =~ m/xen/) {
$model = ("Virtual Machine\n")};
What i am trying to accomplish is if the model is set to "N\A" and the kernel variable has xen somewhere in it i would like to change... (3 Replies)
have issue where my elsif is always failing. Basically i have a file with sets of 2 lines, the 1st line that containing "ipwr" and the 2nd line containing a value or "unknown". if the 2nd line contains a value then i want to print the pair of lines.
open (INFO, "temp.txt") or die;
... (3 Replies)