mikesolomon has asked for the wisdom of the Perl Monks concerning the following question:
I have written a script to find files
I now want to be able to pass it a days parameter and only show files modified in the last x days
How do I do this
Any help acheiving this would be much appreciated
My script so far is below
use strict; use lib 'jumi'; use WebLib; use File::Find; use File::Basename; my ( $folder, $tofind, $tofile, $exclude, $cs ) = @ARGV; my @tofind = split '&&',$tofind; #strip whitespace @tofind = grep(s/\s*$//g, @tofind); @tofind = grep(s/^\s*//g, @tofind); foreach(@tofind) {print "|$_|<br>";} print "<p>Excluded:<br>$exclude</p>"; find(\&wanted, $folder); print qq {<script type="text/javascript">colourRows();</script>}; sub wanted { my $file = $File::Find::name; return unless -T $file; return unless $file =~ /$tofile/; return if $file =~ /$exclude/ && $exclude; if ($tofind) { open F, $file or print "couldn't open $file\n" && return; my $file_contents = do { local $/; <F> }; close F; my $print = 'Y'; foreach (@tofind) { if ($cs == 1){ if ($file_contents !~ /$_/m) {$print = 'N'}; } else { if ($file_contents !~ /$_/mi) {$print = 'N'}; } } if ($print eq 'Y'){ print qq {<tr><td><a href="index.php? option=com_content&view=article&id=21&file=$file" target="_blank"> $file</a></td></tr>}; } #end if } else { print qq {<tr><td><a href="index.php? option=com_content&view=article&id=21&file=$file" target="_blank"> $file</a></td></tr>}; }
|
|---|