in reply to Turning 0755 into rwxr-xr-x
Just in case you wondered how you might go about doing this yourself without using a module:
Of course you are almost certainly better off using the module as it will handle the setuid, setgid and sticky bits properly, but this is by way of example how things are often not as tricky as they seem.sub mode_to_string { my ($mode) = @_; + my @str_mode; + for (0 .. 2) { unshift @str_mode, $mode & 1 ? 'x':'-'; unshift @str_mode, $mode & 2 ? 'w':'-'; unshift @str_mode, $mode & 4 ? 'r':'-'; $mode = $mode >> 3; } + return join '', @str_mode; } + print mode_to_string(0647);
/J\
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Turning 0755 into rwxr-xr-x
by Nkuvu (Priest) on Aug 11, 2005 at 17:40 UTC | |
by gellyfish (Monsignor) on Aug 11, 2005 at 17:54 UTC | |
by Nkuvu (Priest) on Aug 11, 2005 at 18:11 UTC |