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).
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.
Output:
[admin@carbon code_dev]$ ./test2.pl
File: .
MTime: 1044363825
File: carbon.sysbu.2002-11-10.tar.bz
MTime: 1037055058
File: carbon.ibu.2003-01-30.tar.bz2
Can't call method "mtime" on an undefined value at ./test2.pl line 14.
Note: Line 14 is where lstat($_)->mtime is called.
The /mnt/Backup directory contains the following:
[admin@carbon code_dev]$ ls -la /mnt/Backup
total 33337557
drwxr-xr-x 3 root root 4096 Feb 4 05:03 .
drwxr-xr-x 16 root root 1024 Nov 10 19:43 ..
-rw-r--r-- 1 root root 7225819182 Jan 29 04:26
carbon.ibu.2003-01-28.tar.bz2
-rw-r--r-- 1 root root 8307259146 Jan 30 04:52
carbon.ibu.2003-01-29.tar.bz2
-rw-r--r-- 1 root root 9162984332 Jan 31 05:12
carbon.ibu.2003-01-30.tar.bz2
-rw-r--r-- 1 root root 7485649588 Feb 4 05:03
carbon.ibu.2003-02-03.tar.bz2
-rw-r--r-- 1 root root 666488914 Nov 11 14:50
carbon.sysbu.2002-11-10.tar.bz
-rw-r--r-- 1 root root 420932069 Nov 17 19:45
lithium.sysbu.2002-11-17b.tar.bz
-rw-r--r-- 1 root root 835103998 Nov 17 17:13
lithium.sysbu.2002-11-17.tar.bz
drwx------ 2 root root 16384 Nov 10 13:34 lost+found
The filesystem is ext3. The system is Red Hat Linux 7.3 running
kernel-smp-2.4.18-19.7.x. Perl is perl-5.6.1-34.99.6.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]