As an aside just this warning. It seems to me like you want to read file modes from the command line. Be aware that these are strings, and that conversion of string to octal is
not done automatically in a DMIMmy manner, in Perl. In English: if your parameter is "0755" and you treat this as a number, as with
chmod, then perl will convert this to 755 (decimal). Ouch.
You could use something like
$mode= oct($mode) if /^0/;
which can take care of octal (
"0755"), hexadecimal (
"0x1ED") and binary (
"0b111101101") input, as well as decimal (
"493"). But this doesn't give you the full user-friendliness of the command line tool
chmod, which can parse letters combinations along with "+" and "-".
There's basically two solutions, IMO: either you adopt some code, or a module, that deals with these modes (I'd think of one of tye's brainchildren, I forgot the exact name, but it's a node here), or you call the external program chmod with the passed on data. Not that I'd recommend the latter. Not without proper taint checking. (Is the argument really just an argument?)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.