Perl Critic reports
Code before strictures are enabled
Sample script generating this:
examples/critic/no_stricture.pl
print "Hello World\n"; use strict;
TestingAndDebugging::RequireUseStrict
Always have use strict at the beginning of your Perl files.
Related articles:
- Always use strict!
- Always use strict and use warnings in your perl code!
- use strict; and warnings; but no diagnostics
Bareword file handle opened
examples/critic/bareword_file_handle.pl
use 5.010; use strict; open FH, '<', 'data.txt';
InputOutput::ProhibitBarewordFileHandles
Two-argument "open” used
examples/critic/two_argument_open.pl
use 5.010; use strict; open my $fh, 'data.txt';
InputOutput::ProhibitTwoArgOpen
"return" statement with explicit "undef"
examples/critic/return_undef.pl
use 5.010; use strict; sub f { return undef; }
Subroutines::ProhibitExplicitReturnUndef
- How to return nothing (or undef) from a function in Perl?
- wantarray - returning list or scalar based on context
Nested named subroutine
examples/critic/nested_subs.pl
use 5.010; use strict; sub f { sub g { } }
Subroutines::ProhibitNestedSubs
Package declaration must match filename
Three-argument form of open used .... Three-argument open is not available until perl 5.6.
Use of "open" is not allowed ..... Use file operation methods of MainObject instead.
I/O layer ":utf8" used .... Use ":encoding(UTF-8)" to get strict validation.
Published on 2018-12-21