Michelle Konzack wrote:
Hello,
Hello,
I have a similar problem but with "mode" which output weird permissions:
----[ '~/bin/.perl_test_001' ]------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use File::stat;
opendir(DH, "/home/michelle.konzack/bin") || die "$!";
my @dir=readdir DH;
foreach (@dir)
{
my $FILE=$_;
my $FILESTAT=stat("/home/michelle.konzack/bin/" . $_);
my $MODE=$FILESTAT->mode;
printf "%-30s %s\n", $FILE, $MODE;
}
------------------------------------------------------------------------
and the output is something like:
----[ command '.perl_test_001' ]----------------------------------------
<snip>
.perl_test_001 33279
[snip]
where "perl_test_001" has mode 0777.
Whats wrong here?
$ perl -le'printf "%o\n", 33279'
100777
33279 is the decimal representation of a number, and 0777 is the octal
representation of a number. If a number has a leading zero it is
usually displayed in octal representation.
$ perl -le'print for 0777, 777'
511
777
So 0777 is the octal representation of the decimal number 511.
Perl can display numbers in either decimal, hexadecimal, octal or binary
formats:
$ perl -le'printf "%1\$#d %1\$#x %1\$#o %1\$#b\n", 777'
777 0x309 01411 0b1100001001
Perl can also use literal numbers represented in either decimal,
hexadecimal, octal or binary formats:
$ perl -le'printf "%s %s %s %s\n", 777, 0x309, 01411, 0b1100001001'
777 777 777 777
What I do not understand is:
----[ perldoc 'File::stat' ]--------------------------------------------
BUGS
As of Perl 5.8.0 after using this module you cannot use the
implicit $_ or the special filehandle "_" with stat() or
lstat(), trying to do so leads into strange errors. The
workaround is for $_ to be explicit
my $stat_obj = stat $_;
That is not related to your problem.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/