in reply to Finding Last minute file in a directory

Dear Monks
Thanks for your hlep. Could you please guide me with a code for date time function.
I now understand the benefit of making a single call but I still have the issue in getting the actual file time stamp. Is there any other way I can get it, how about the mtime, atime function. Thanks
  • Comment on Re: Finding Last minute file in a directory

Replies are listed 'Best First'.
Re^2: Finding Last minute file in a directory
by John007 (Acolyte) on Aug 16, 2009 at 16:52 UTC
    Dear zwon,
    I ran your code, I only have perl 5.8 version so it errored out for that and it also gave me other problems.
    #!/usr/bin/perl use Data::Dumper; use Time::localtime; use File::stat; use Term::ANSIColor; use Net::FTP; use warnings; use File::Spec; my $dirname = '.'; opendir( my $dir, $dirname ) or die $!; my $file; while ( $file = readdir($dir) ) { last if ( stat( File::Spec->catfile( $dirname, $file ) ) )[9] + 60 + > time; $file = ''; }

      The only 5.10 feature I've used is say and you can replace it by print. I recommend you to use strict as it helps to prevent some errors. Do you have any other problems with my example?