|
|
| No such thing as a small change | |
| PerlMonks |
Re^3: state and file perms confusionby Tanktalus (Canon) |
| on Aug 04, 2012 at 13:55 UTC ( #985434=note: print w/ replies, xml ) | Need Help?? |
|
There aren't a lot of use cases for storing an octal "number" in a scalar. There are some, but they're all to do with formatting output, not actual use as a number. If your goal is to use this for chmod, you have to realise that it won't work. If you do this: you'll actually be doing the same thing as this: Definitely not what you wanted. Leave the number as-is if you plan on using it in chmod. Note that the following lines are equivalent: So, to answer your question, the number is already in the scalar. You don't actually need to do anything about it. And, if you use $mode = sprintf "%o", $mode;, remember what you just did: you took a number, you printf'd it into a string, and put that back in $mode. So $mode no longer carries a number but a string. Perl will try to force it back to a number if that's what you try to do, but it won't be the number you started with.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||