G'day Neil,

To be honest, that does sound like a typo somewhere in your code using oct. You haven't shown that code so please confirm that with these lines:

my $mode = $sb[2] & 0777; ... ok( ! ( $mode & 022 ), "File is not group or world writable" );

Test 3 passes and you get those 2 perlcritic warnings.

But, when changing those lines to:

my $mode = $sb[2] & oct(777); ... ok( ! ( $mode & oct(22) ), "File is not group or world writable" );

Test 3 fails but you get those 0 perlcritic warnings.

And do note that I've removed the leading zeros for the oct arguments: oct(0777) and oct(022) will still generate the perlcritic warnings.

If you believe you have checked closely and there's no typos, can you provide a short, self-contained script to reproduce the problem that we can run.

I did actually try to reproduce it with the script I posted in response to your last question regarding this "Testing for group or world writable files". Without oct, I got 4 passes and 4 perlcritic warnings; with oct, I got 4 passes and 0 perlcritic warnings.

Personally, although there's much about PBP I like, this isn't one of them: you're working with modes, there's a variable called $mode (so that's somewhat obvious), modes are in octal, why complain about octal numbers. If you're of the same view, just turn the warnings off (in the smallest scope possible):

## no critic (LeadingZeros) my $mode = $sb[2] & 0777; ## use critic ... ## no critic (LeadingZeros) ok( ! ( $mode & 022 ), "File is not group or world writable" ); ## use critic

-- Ken


In reply to Re: Perlcritic and checking file modes by kcott
in thread Perlcritic and checking file modes by neilwatson

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.