Hi

I've recently been trying to catch up and improve my Perl skills. That includes trying to get my code to pass perlcritic (with suitable configuration) and trying to use Dist::Zilla to automate builds. However I keep running into a problem:

PkgVersion adds a line setting $VERSION after each package line, saving the bother of updating these by hand and the probable inconsistencies caused by that.

However, Perl::Critic::(...)::RequireUseStrict will complain about the version setting code coming before use strict; in the module. (same applies for ...::RequireUseWarnings)

If I move use strict; use warnings; before the package statement, Perl::Critic::(...)::RequireExplicitPackage complains that I have code outside of an explicit package.

I would like to keep both of these policies to tell me about mistakes. However in this case the violations seem harmless, right?

I am also wondering, is there a reason to prefer one of

use strict; use warnings; package Foo; ...

versus

package Foo; use strict; use warnings; ...

Is one more helpful than the other?

My current thinking is that it will be best to modify Dist::Zilla::Plugin::PkgVersion to put the version number after strictures. However, this might be quite hard. So before I start, has anyone else solved this or got a suggestion for a better solution?

Thanks

FalseVinylShrub

Disclaimer: Please review and test code, and use at your own risk... If I answer a question, I would like to hear if and how you solved your problem.


In reply to Dist::Zilla::Plugin::PkgVersion vs. Perl::Critic and strictures by FalseVinylShrub

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.