Perl::Critic::Policy::ControlStructures::ProhibitYadaOperator - Never use ... in production code. River stage three • 113 direct dependents • 455 total dependents

The yada operator "..." is not something you'd want in production code because it will throw an exception when executed. However, it is perfectly useful in less critical environments as a placeholder for code not yet implemented....

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ControlStructures::ProhibitUnlessBlocks - Write if(! $condition) instead of unless($condition). River stage three • 113 direct dependents • 455 total dependents

Conway discourages using "unless" because it leads to double-negatives that are hard to understand. Instead, reverse the logic and use "if". unless($condition) { do_something() } #not ok unless(! $no_flag) { do_something() } #really bad if( ! $condit...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Modules::RequireNoMatchVarsWithUseEnglish - use English must be passed a -no_match_vars argument. River stage three • 113 direct dependents • 455 total dependents

Due to unfortunate history, if you use the English module but don't pass in a "-no_match_vars" argument, all regular expressions in the entire program, not merely the module in question, suffer a significant performance penalty, even if you only impo...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::ProhibitComplexMappings - Map blocks should have a single statement. River stage three • 113 direct dependents • 455 total dependents

The map function can be confusing to novices in the best of circumstances. Mappings with multiple statements are even worse. They're also a maintainer's nightmare because any added complexity decreases readability precipitously. Why? Because map is t...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::ProhibitNoisyQuotes - Use q{} or qq{} instead of quotes for awkward-looking strings. River stage three • 113 direct dependents • 455 total dependents

Don't use quotes for one or two-character strings of non-alphanumeric characters (i.e. noise). These tend to be hard to read. For legibility, use "q{}" or a named value. However, braces, parentheses and brackets tend to look better in quotes, so thos...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::NamingConventions::ProhibitAmbiguousNames - Don't use vague variable or subroutine names like 'last' or 'record'. River stage three • 113 direct dependents • 455 total dependents

Conway lists a collection of English words which are highly ambiguous as variable or subroutine names. For example, $last can mean previous or final. This policy tests against a list of ambiguous words for variable names....

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::Subroutines::ProhibitUnusedPrivateSubroutines - Prevent unused private subroutines. River stage three • 113 direct dependents • 455 total dependents

By convention Perl authors (like authors in many other languages) indicate private methods and variables by inserting a leading underscore before the identifier. This policy catches such subroutines which are not used in the file which declares them....

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::RequireConstantVersion - Require $VERSION to be a constant rather than a computed value. River stage three • 113 direct dependents • 455 total dependents

The $VERSION variable of a module should be a simple constant - either a number, a single-quotish string, or a 'use version' object. In the latter case the 'use version;' must appear on the same line as the object construction. Computing the version ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::ProhibitComplexVersion - Prohibit version values from outside the module. River stage three • 113 direct dependents • 455 total dependents

One tempting way to keep a group of related modules at the same version number is to have all of them import the version number from a designated module. For example, module "Foo::Master" could be the version master for the "Foo" package, and all oth...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::ProhibitLeadingZeros - Write oct(755) instead of 0755. River stage three • 113 direct dependents • 455 total dependents

Perl interprets numbers with leading zeros as octal. If that's what you really want, its better to use "oct" and make it obvious. $var = 041; # not ok, actually 33 $var = oct(41); # ok chmod 0644, $file; # ok by default dbmopen %database, 'foo.db', 0...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ControlStructures::ProhibitCascadingIfElse - Don't write long "if-elsif-elsif-elsif-elsif...else" chains. River stage three • 113 direct dependents • 455 total dependents

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; } elsi...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ControlStructures::ProhibitUnreachableCode - Don't write code after an unconditional die, exit, or next. River stage three • 113 direct dependents • 455 total dependents

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...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock - Sort blocks should have a single statement. River stage three • 113 direct dependents • 455 total dependents

Conway advises that sort functions should be simple. Any complicated operations on list elements should be computed and cached (perhaps via a Schwartzian Transform) before the sort, rather than computed inside the sort block, because the sort block i...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::BuiltinFunctions::ProhibitSleepViaSelect - Use Time::HiRes instead of something like select(undef, undef, undef, .05). River stage three • 113 direct dependents • 455 total dependents

Conway discourages the use of "select()" for performing non-integer sleeps. Although documented in perlfunc, it's something that generally requires the reader to read "perldoc -f select" to figure out what it should be doing. Instead, Conway recommen...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::RegularExpressions::RequireExtendedFormatting - Always use the /x modifier with regular expressions. River stage three • 113 direct dependents • 455 total dependents

Extended regular expression formatting allows you mix whitespace and comments into the pattern, thus making them much more readable. # Match a single-quoted string efficiently... m{'[^\\']*(?:\\.[^\\']*)*'}; #Huh? # Same thing with extended format......

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::RegularExpressions::RequireDotMatchAnything - Always use the /s modifier with regular expressions. River stage three • 113 direct dependents • 455 total dependents

When asked what "." in a regular expression means, most people will say that it matches any character, which isn't true. It's actually shorthand for "[^\n]". Using the "s" modifier makes "." act like people expect it to. my $match = m< foo.bar >xm; #...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::ProhibitEmptyQuotes - Write q{} instead of ''. River stage three • 113 direct dependents • 455 total dependents

Don't use quotes for an empty string or any string that is pure whitespace. Instead, use "q{}" to improve legibility. Better still, created named values like this. Use the "x" operator to repeat characters. $message = ''; #not ok $message = ""; #not ...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ControlStructures::ProhibitCStyleForLoops - Write for(0..20) instead of for($i=0; $i<=20; $i++). River stage three • 113 direct dependents • 455 total dependents

The 3-part "for" loop that Perl inherits from C is butt-ugly, and only really necessary if you need irregular counting. The very Perlish ".." operator is much more elegant and readable. for($i=0; $i<=$max; $i++){ #ick! do_something($i); } for(0..$max...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::RegularExpressions::ProhibitCaptureWithoutTest - Capture variable used outside conditional. River stage three • 113 direct dependents • 455 total dependents

If a regexp match fails, then any capture variables ($1, $2, ...) will be unaffected. They will retain whatever old values they may have had. Therefore it's important to check the return value of a match before using those variables. '12312123' =~ /(...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

Perl::Critic::Policy::ValuesAndExpressions::ProhibitVersionStrings - Don't use strings like v1.4 or 1.4.5 when including other modules. River stage three • 113 direct dependents • 455 total dependents

Whenever you "use" or "require" a module, you can specify a minimum version requirement. To ensure compatibility with older Perls, this version number should be expressed as a floating-point number. Do not use v-strings or three-part numbers. The Per...

PETDANCE/Perl-Critic-1.134 - 23 May 2019 02:52:21 GMT

197 results (0.106 seconds)