in reply to Finding Oldest File in a Directory

You're calling stat on files within $dirname, but you're not in $dirname. Change your stat call to:

   my $x = stat("$dirname/$file")->mtime;

Alternately you could chdir() to $dirname and make your stats the same way you are now.

-sam

Replies are listed 'Best First'.
Re^2: Finding Oldest File in a Directory
by Aristotle (Chancellor) on Oct 08, 2005 at 19:34 UTC

    Yep. It would be better yet to use File::Spec though.

    use File::Spec::Functions qw( catfile ); # ... my $x = stat( catfile $dirname, $file )->mtime;

    Makeshifts last the longest.