Tuna has asked for the wisdom of the Perl Monks concerning the following question:
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.#!/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++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Date Range Parsing
by davorg (Chancellor) on Feb 15, 2001 at 21:48 UTC | |
by Tuna (Friar) on Feb 15, 2001 at 21:56 UTC | |
|
Re: Date Range Parsing
by chipmunk (Parson) on Feb 15, 2001 at 21:10 UTC | |
by Tuna (Friar) on Feb 15, 2001 at 21:27 UTC | |
by chipmunk (Parson) on Feb 15, 2001 at 21:37 UTC | |
|
Re: Date Range Parsing
by boo_radley (Parson) on Feb 15, 2001 at 21:23 UTC | |
|
Re: Date Range Parsing
by stefan k (Curate) on Feb 15, 2001 at 21:10 UTC |