On Sun, 14 Oct 2007 19:55:35 +0800,
Amy Lee <> wrote:
> On Sun, 14 Oct 2007 19:44:35 +0800, Amy Lee wrote:
>
>> Hello,
>>
>> I write a perl script to show the file mask like -rwxr-xr-x is 0755, but
>> when I run my script, it shows 835 in this mode. I don't know why.
[snip]
>> my($mode) = stat($file);
>> print "$file ==> $mode\n";
> I change this part:
>
> my($mode) = stat($file); to
>
> my($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime,
> $ctime, $blksize, $blocks) = stat($file);
>
> However, it's useless, what happened?
Print the mode in octal. The permissions you refer to above are octal
numbers, but you print them in decimal.
#!/usr/bin/perl
use warnings;
use strict;
for my $f (@ARGV)
{
my ($mode) = (stat $f)[2];
printf "$f: %o\n", $mode;
}
Martien
--
|
Martien Verbruggen |
| The gene pool could use a little chlorine.
|
|