0

Im getting Code before warnings are enabled from perl::critic, even though I have -w specified in the shebang

#!/usr/bin/perl -w

I Really don't want to have to go through and replace all instances. Is there anything I can do. Additionally, I do want perl::critic to ensure all perl has warnings enabled.

4

1 回答 1

3

You say perlcritic doesn't do what you want, but that you want it to do what you want. As such, you will need modify perlcritic, or more specifically, Perl:: Critic:: Policy:: TestingAndDebugging:: RequireUseWarnings. You should have no problems getting your changes accepted because the lack of shebang parsing is listed as a bug in the documentation.


It might be simpler to edit your files. It's quite trivial to do so mechanically. Assuming you already use use strict;,

find -type f \( -name '*.pl' -o -name '*.pm' \) ! -name '*~' -exec \
   perl -i~ -0777pe's/^(\s*)use strict\b.*\n\K/${1}use warnings;\n/mg' {} +
于 2014-11-27T14:10:04.573 回答