#!/usr/bin/perl use strict; use warnings; use 5.014; use File::Find; use Data::Dumper; # after oko1's #956137 - First, this for comparison with original output: my ($dir, @files); print "Provide the 'Drive:/path/to/dir/' (nix-ish slashes) you want to explore: "; { no warnings; $dir = or die "Can't read supplied path/to/dir/, $!"; chomp $dir; say "Got target: $dir\n\n"; say "... next, foreaching the \@files array..." } # end bareblock 'no warnings' # files selected based on listing in newest per find_newest.pl (not shown, but essentially as in the second stanza of this demo) # plus a few others believed to be older than the top 20: @files = ('D:\Sch_new1\pvt\sch_ftp_Admin.txt', 'D:\Sch_new1\911\SLFD.htm', 'D:\Sch_new1\docs\pb_draft.htm', 'D:\Sch_new1\Archive\DL20120208.htm', 'D:\Sch_new1\Hist\GenIndex.htm', 'D:\Sch_new1\cal\cal.htm', 'D:\Sch_new1\quadri\HFCindex.htm', 'D:\Sch_new1\cgi-bin\test\test.cgi', 'D:\Sch_new1\INFOlinks.htm', 'D:\Sch_new1\Archive\events07_files\Drost_memorial.jpg', 'D:\Sch_new1\Archive\PBZBA\scope.htm', 'D:\Sch_new1\911\cvas\a14.htm', 'D:\Sch_new1\reval\assess_mail.htm', 'D:\Sch_new1\ww\psycho_eliza_tutorial1.htm', 'D:\Sch_new1\911\GenlFire\AltMltXHistory.htm', 'D:\Sch_new1\cgi-bin\webmstr.pl', 'D:\Sch_new1\gfx\Lubbers.jpg', 'D:\Sch_new1\plan_tmp\JiminoDollarTree19Jan.pdf', 'D:\Sch_new1\911\SSFD_Gfx\ff2009.jpg', 'D:\Sch_new1\911\coons\bio.htm', 'D:\Sch_new1\css\style.css', 'D:\Sch_new1\webmstr.htm,', 'D:\Sch_new1\xfer.htm', 'D:\Sch_new1\xferNEW.htm', 'D:\Sch_new1\y+r.htm', 'D:\Sch_new1\zba_sked.htm', 'D:\Sch_new1\zone.htm' ); my ($file, $dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks); for $file(@files) { chomp $file; # $file = $dir . $file; # used for vers 1 of array @files ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat $file or warn "\t Can't stat $file, $!"; no warnings qw(uninitialized); unless (! $file) { say "$file: $dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, \$atime: $atime, \$mtime: $mtime, \$ctime: $ctime, |\$blksize: $blksize|, |\$blocks: $blocks|"; # ctime, blksize and blocks are expected to fail in various ways: $ctime is unreliable on windows # and $blksize and $blocks are undef } use warnings; #restore } say "\n\t\t Now running the prior code"; # old code follows my %dirs; finddepth(\&newest, $dir); sub newest { return unless -f; my ($d, $n) = ($File::Find::dir, $File::Find::name); # say $d, $n; $dirs{$d} ||= $n; $dirs{$d} = $n if (stat($n))[9] > (stat($dirs{$d}))[9]; # mtime } say "\n"; say "$_: $dirs{$_}" for keys %dirs;