in reply to Re: Unix File Type with stat
in thread Unix File Type with stat

What does the $mode & 07777 do? Could you explain it in layman's terms. I am not familiar with this type of expression as I am very new to Perl.

Replies are listed 'Best First'.
Re: Re: Unix File Type with stat
by Helter (Chaplain) on Sep 10, 2002 at 13:05 UTC
    I'm not sure there is a "laymans" terms explanation for this. A single & is a bitwise and. This means it will go through the left and right, compare them bit by bit and the result is determined by the and function:
    src1 src2 dest 0 0 0 0 1 0 1 0 0 1 1 1
    In your example src1 is $mode, src2 is 07777 and dest is $perms. This is mostly used to zero out bits, or mask off portions of bits.
    The bitwise or operator, |, is used to set bits in a bit-string.
    Hope this helped.