How about something like this?
#/usr/bin/perl -w
use strict; # always a good idea
my $newfile = '/perl/bin/newr';
# consider File::Find, if you'd like to be recursive
# also, always check the return value of opendir
# (I suspect this may be the root of your problems)
opendir(DIR,$newfile) or die "Unable to opendir!";
my @files = readdir(DIR);
close(DIR);
foreach (@files) {
print "File: $_\n";
my($atime,$mtime) = (stat($_))[8,9];
print "atime: " . localtime($atime) . "\n";
print "mtime: " . localtime($mtime) . "\n";
}
Cheers,
Shendal