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

null
  • 889
  • 1
  • 13
  • 24
  • 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. – simbabque Aug 12 '14 at 08:02
  • @tjd To state the obvious that you missed, example is the relevant lines, not the entire file. – null Aug 12 '14 at 16:05

1 Answers1

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.

Ralf
  • 355
  • 1
  • 4