Arild Jensen wrote:
I am trying to get the mtime of a bunch of files and directores. However, it fails after the first two files/dirs. I don't see why it should. I am an experienced sysadmin and a beginner Perl coder (obviously).I am curious if this is a bug in Perl's implementation of File::stat, from the 5.8.0 perldoc File::stat:
Help.
Source code:
#!/usr/bin/perl -w
use strict;
use File::Find;
use File::stat;
find(\&syswanted, '/mnt/Backup');
#########################################################################
sub syswanted {
my $current_mtime;
print "File: $_\n";
$current_mtime = lstat($_)->mtime;
print "MTime: $current_mtime \n";
}
#########################################################################
# The end.
"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."
I realize you said you are using 5.6.1 but this seems rather strange, you might consider trying the regular built-in stat/lstat. (Do you really want lstat over stat, there were no symlinks in your list?)
sub syswanted {
my $file = $_;
print "File: $file\n";
$current_mtime = (stat($file))[9];
print "MTime: $current_mtime\n";
}
perldoc -f stat
perldoc -f lstat
perldoc File::stat (see if there is a 'Bugs' entry in 5.6.1)
Sorry I don't have a 5.6.1 install around I can test with....
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]