#!/usr/bin/perl # ################################################################### # # Name: getfiledates.pl # Version: 1.2 # Author: pete@rasterweb.net # Date Created: 03.25.2002 # Date Modified: 04.24.2002 # # run it like so: # perl getfiledates.pl 1 # and it'll drill down into whatever the current working directory # is and give you any files modified it the last X hours (we're # using 1 hr int he example...) # # TO DO: allow you to specify a dir, and dirs to skip # right now we skip RCS and ORIG cuz I wrote it that way... # # ...your foo may vary... # # This is free software, you may use it and distribute it under the # same terms as Perl itself. # #################################################################### #################################################################### # use use File::Find; use Cwd; $hrsold = shift; $hrsold = 1 if ($hrsold < 1); $thedir = cwd; @dirs = ($thedir); find(\&getfiles, @dirs); @keys = sort{$hash{$b} cmp $hash{$a}} keys %hash; foreach $item (@keys) { $localtime = localtime($hash{$item}); printf "%-25s %s\n", $localtime, $item; }; ################### # subs below here # #################################################################### #################################################################### sub getfiles { my $file = $File::Find::name; my $dir = $File::Find::dir; my $prettydir = ''; if (!(-d ($file))) { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat($file); $oldtime = (time - (3600 * $hrsold)); # how many hrs old / 3600 secs per hour if ($dir !~ /RCS|ORIG/i) { if ($mtime > $oldtime) { $myfile = $file; $myfile =~ s/$thedir/$prettydir/g; $localtime = localtime($mtime); # printf "%-25s %s\n", $localtime, $myfile; $hash{$myfile} = $mtime; } } } } # end sub getfiles __END__