Funny, I've begun this question and killed it to try some things on my own about 5 times this morning! Anyway, my problem is that I want to "do something" to files created within a certain range of dates, inclusively. And I'm stuck. Here's what I've got so far; be gentle as I'm new at this programming stuff.
#!/usr/local/bin/perl -w
use strict;
my $test_arg = $ARGV[0];
my @string = split('-',$test_arg);
my $beg_date = $string[0];
my $end_date =$string[1];
my $date = $beg_date;
my @list;
if ($string[0] ge $string[1]) {
die "Invalid date range\n";
}
elsif ($test_arg =~ /\d{8}-\d{8}/){
$test_arg = "1";
}
else {
$test_arg = "0";
}
die "Usage: $0 <yyyymmdd-yyyymmdd>\n" unless $test_arg == "1";
while ($date <= $end_date){
push (@list, $date);
}
continue {
$date++;
}
The array
@list is getting populated by the date string that I will use for my file search. My problem is accounting for the fact that months have either 28, 29, 30, or 31 days, depending upon year and month.
As writtren, the given date range 20010101-20010201 will return 100 days!