Perl::Critic 'Code before strictures' when using Modern::Perl
Asked Answered
H

1

6

I understand that it is best practice to use Modern::Perl rather than use strict and warnings.

With default options, Perl::Critic v1.121 complains about code before strict, even when 'use Modern::Perl' comes before code.

QUESTION: Is the best solution to update the perlcriticrc config like below, or is there a better way?

Source of config below

cat ~/.perlcriticrc

[TestingAndDebugging::RequireUseStrict]
equivalent_modules = Modern::Perl

[TestingAndDebugging::RequireUseWarnings]
equivalent_modules = Modern::Perl

Also of note: Developer Discussion Here

Hoffert answered 12/8, 2014 at 6:54 Comment(2)
Looks pretty obvious to me from the discussion. There's on other way as to include it there. You could turn off the warning, but that wouldn't make sense at all.Implication
@tjd To state the obvious that you missed, example is the relevant lines, not the entire file.Hoffert
F
3

You can "use 5.014" (or higher if available) to implicitly enable "use strict" right in the first line. Perl::Critic likes this native approach much more. After that you are free to still invoke use Modern::Perl if you still feel the need.

Feer answered 3/9, 2014 at 21:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.