in reply to accessing file attibutes
$file =~ <DIR>??? Try defined($file = readdir(DIR))
Update: Furthermore, don't forget that readdir only returns a file name, not a complete path.
#!/usr/bin/perl use strict; use warnings use File::Spec qw( ); my $dir = '/cdw/dept/dss/home_dir/s006258'; opendir($dh, $dir) or die "Unable to open directory '$dir': $!\n": while (defined(my $file = readdir($dh))) { my $path = File::Spec->catfile($dir, $file); my $mtime = (stat($path))[9]; printf("%s was last modified on %s\n", $file, scalar(localtime($mtime)), ); } closedir $dh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: accessing file attibutes
by Anonymous Monk on Nov 15, 2006 at 20:44 UTC | |
by Joost (Canon) on Nov 15, 2006 at 20:47 UTC | |
by Anonymous Monk on Nov 15, 2006 at 20:54 UTC | |
by Joost (Canon) on Nov 15, 2006 at 21:06 UTC | |
by runrig (Abbot) on Nov 15, 2006 at 23:04 UTC | |
by Anonymous Monk on Nov 15, 2006 at 21:14 UTC | |
by ikegami (Patriarch) on Nov 15, 2006 at 22:45 UTC |