Is there an elegant way in Perl to find the newest file in a directory (newest by modification date)?
What I have so far is searching for the files I need, and for e
Subject is old, but maybe someone will try it - it isn't portable (Unix-like systems only), but it's quite simple and works:
chdir $directory or die "cannot change directory"; my $newest_file = bash -c 'ls -t | head -1'; chomp $newest_file; print "$newest_file \n";
chdir $directory or die "cannot change directory";
my $newest_file = bash -c 'ls -t | head -1';
bash -c 'ls -t | head -1'
chomp $newest_file;
print "$newest_file \n";