in reply to Re^2: Turning 0755 into rwxr-xr-x
in thread Turning 0755 into rwxr-xr-x

Er, well you would be right if you weren't missing the fact that the mode here is actually an octal number that has to begin with a zero in Perl - that is to say 0755 will work fine whereas the 755 will not.

This is probably even easier to understand if you do:

my $mode = (stat('.'))[2] & 07777; print $mode ,"\n"; printf "%o\n", $mode ; print mode_to_string($mode);
Where the 07777 is a mask to remove the filetype information from the mode (as described in perlfunc).

/J\

Replies are listed 'Best First'.
Re^4: Turning 0755 into rwxr-xr-x
by Nkuvu (Priest) on Aug 11, 2005 at 18:11 UTC
    Actually I see the issue now. I copied your sub, and changed to 755 in the code, which didn't work (for obvious reasons). Then I wrapped an input loop around it so that I could test different values, and 755 and 0755 are both read in as decimal values. Makes sense now. Sorry, been a long week.