I am trying to search through all my files for a string that contains a date. I want to be able to find any file with a date that falls during this current week. I am able to pull the files that contain todays date, but I can't seem to search for more than one at a time. Any suggestions on how to accomplish this?
@days=(Sun,Mon,Tue,Wed,Thu,Fri,Sat);
@months=(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
$time=time;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($time)
+;
$year += 1900;
$eday = $mday + 6;
$sdate ="$months[$mon] $mday";
$edate="$months[$mon] $eday";
#-- Output -----------------------------------
print header();
print start_html();
print "\n<p>The following files contain content that will expire durin
+g $sdate - $edate:</p>\n<ul>\n";
find( sub
{
return if($_ =~ /^\./);
return unless($_ =~ /\.(cfm|htm|cfml|html|txt)/i);
stat $File::Find::name;
return if -d;
return unless -r;
open(FILE, "< $File::Find::name") or return;
my $string = <FILE>;
close (FILE);
return unless ($string =~ /\Q$edate/i);
my $page_title = $_;
if ($string =~ /<title>(.*?)<\/title>/is)
{
$page_title = $1;
}
my $foundFile = $File::Find::name;
print "<li><a href=\"$foundFile\">$File::Find::name</a></li>\n
+";
},
'/inetpub/mysite');
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.