my $d = "16895"; my $f = "33206"; my $od = sprintf("%5o",$d); my $of = sprintf("%5o",$f); print "$d->$od\n$f->$of\n"; my $d = "16877"; my $f = "33188"; my $od = sprintf("%5o",$d); my $of = sprintf("%5o",$f); print "$d->$od\n$f->$of\n"; # get the three lowest bits (use the INTEGER value for this, not the o +ctal string!) my $l3b = $d & 7; # 0000111 in binary, or '7' in octal and in dec print "lowest three bits of octal $od is $l3b\n"; # get the three bits starting at bit 4 (111000 in bin, 70 in oct, 56 d +ec) my $l43b = $d & oct(70); # still 6 bits though, $l43b = $l43b >> 3; print "$od and oct(70) shifted 3 bits to the right = ",sprintf("%o",$l +43b)," in octal\n";
gives
16895->40777 33206->100666 16877->40755 33188->100644 lowest three bits of octal 40755 is 5 40755 and oct(70) shifted 3 bits to the right = 5 in octal

In reply to Re^2: POSIX::S_ISDIR() ... octal strings, bit manipulations by Sandy
in thread POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux by isync

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.