in reply to Re: Turning 0755 into rwxr-xr-x
in thread Turning 0755 into rwxr-xr-x
So I revised the sub a bit:
sub split_mode_to_string { my @sections = reverse split '', $_[0]; my @str_mode; for my $mode (@sections) { unshift @str_mode, $mode & 1 ? 'x':'-'; unshift @str_mode, $mode & 2 ? 'w':'-'; unshift @str_mode, $mode & 4 ? 'r':'-'; } return join '', @str_mode; }
Which gives the right permissions for 755. As well as all of the other tests I tried (001, 010, 100, et cetera). I think the issue with the original sub is that 755 shifted right by 3 is not 75 -- it's 94.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Turning 0755 into rwxr-xr-x
by gellyfish (Monsignor) on Aug 11, 2005 at 17:54 UTC | |
by Nkuvu (Priest) on Aug 11, 2005 at 18:11 UTC |