Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
# This $localtime is going to give me: "Fri Jan 27 12:11:15 2006" as an example.our $localtime = localtime;
Now, if [Dec 23 15:40:06 2005] is one month older from today's date I have to delete that line from the file(s) and archive it.[Dec 23 15:40:06 2005] derror.txt : Test application module :: Error:: +file_log ::: Bad file descriptor
## OPEN AND READ THE DIRECTORY #=comment opendir (DIR, "$dir"); my @FILES = grep(/.txt/,readdir(DIR)); closedir (DIR); foreach my $FILES (@FILES) { open FILE, "$dir/$FILES" or warn "Can't open $FILES: $!<br>\n", n +ext; while(<FILE>){ my $check = $_; + if($check=~/(^\[)(\w+)(\s)(\w+)(\s)(\d+)(.*?)$/isg){ print "**** $2** $4**$6**$7**<br>";} } close FILE; } }
jdporter added more code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing Dates
by duff (Parson) on Jan 27, 2006 at 19:28 UTC | |
|
Re: Comparing Dates
by CountZero (Bishop) on Jan 27, 2006 at 20:46 UTC | |
by bowei_99 (Friar) on Jan 28, 2006 at 01:06 UTC | |
|
Re: Comparing Dates
by ptum (Priest) on Jan 27, 2006 at 19:27 UTC | |
|
Re: Comparing Dates
by philcrow (Priest) on Jan 27, 2006 at 19:26 UTC | |
|
Re: Comparing Dates
by tcf03 (Deacon) on Jan 29, 2006 at 12:32 UTC | |
|
Re: Comparing Dates
by olus (Curate) on Jan 30, 2006 at 02:46 UTC |