See
Date::Calc, for starters.
UPDATE:
I cooked up a solution that would work for my personal file naming convention.
Consider a directory full of files like: summary.interfaces.yyyymmdd
I could run the following code, and simply grep this directory for all files ending in "$period".
#!/usr/local/bin/perl -w
use strict;
#Usage: $0 <yyyy> <1 2 3> #period 1,2,3, that is
die "Usage: $0 <yyyy> <1 2 3>, #period 1,2,3, that is\n" unless @ARGV
+==2;
my $prepend = $ARGV[0];
my $per = $ARGV[1];
my @period;
my @files;
if ($per eq 1) {
@period = ("$prepend"."0101", "$prepend"."0630");
}
elsif ($per eq 2) {
@period = ("$prepend"."0701", "$prepend"."0831");
}
elsif ($per eq 3) {
@period = ("$prepend"."0901", "$prepend"."1231");
}
else {die "Usage: $0 <yyyy> <1 2 3>, #period 1,2,3, that is\n";}
foreach my $element(@period) {
print "$element\n";
}
my $from = $period[0];
my $to = $period[1];
while ( $from < $to ) {
print "$from\n";
} continue {
$from++;
}
Certainly not the prettiest, but it would work for me.
HTH,
Steve
update again:corrected typo
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.