#!/usr/bin/perl -w # Display the latest file in a given directory tree, ignoring .svn directories # [JNZ] Modified 07-May-2008 # Usage: latest dir [...] use POSIX qw(strftime); use File::Find qw(find); $n = ""; $nt = -1; sub latest { # Ignore .svn directories if ((-d $_) && /\/\.svn$/) { $File::Find::prune = 1; return; } # If the searched file is NOT a link, but is a file, and the mtime is # later than that stored in $nt, store the results for later. if ((! -l $_) && (-f _) && (stat(_))[9] > $nt) { $n = $_; $nt=(lstat(_))[9]; } } if ($#ARGV < 0) { @ARGV = ("."); } find({wanted => \&latest, no_chdir => 1}, @ARGV); print "$n ", strftime("%Y.%m.%d", gmtime($nt)), "\n";