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). > > #!/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; # line 14 > print "MTime: $current_mtime \n"; > }
> 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. Hi Arild. Your call to 'lstat' is clearly failing and returning 'undef'. Try finding out why with: my $lstat = lstat($_) or die "lstat($_) failed: $!"; $current_mtime = $lstat->mtime; HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]