PerlCritic rules are sometimes just good suggestions, and often the experienced programmer will know better.

$ perlcritic --verbose 11 foo.pl "require" statement with library name as string at line 6, near 'requi +re '/tmp/config.pl';'. Modules::RequireBarewordIncludes (Severity: 5) When including another module (or library) via the `require' or `u +se' statements, it is best to identify the module (or library) using a bareword rather than an explicit path. This is because paths are u +sually not portable from one machine to another. Also, Perl automatically assumes that the filename ends in '.pm' when the library is expres +sed as a bareword. So as a side-effect, this Policy encourages people to +write '*.pm' modules instead of the old-school '*.pl' libraries. use 'My/Perl/Module.pm'; #not ok use My::Perl::Module; #ok

So this means the rule exists because its author(s) were worried that people are writing Perl-4-style libraries. Since in this case you know better and config.pl is not a library, you are free to overrule PerlCritic:

require '/tmp/config.pl'; ## no critic (RequireBarewordIncludes)

Of course there are other ways to "fix" the issue, e.g. to use do or even eval (but require is fine). Also, you could just turn config.pl into MyConfig.pm and make things easier that way too.


In reply to Re: What's the right way to include a config file as a .pm bareword? by Anonymous Monk
in thread What's the right way to include a config file as a .pm bareword? by Cody Fendant

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.