On Sep 10, 7:18 am, [EMAIL PROTECTED] (Mathew Snyder) wrote: > I have a script which has to be manually edited to run for a span of days. > When > these days are over several weeks it can be clearly tedious to enter dates in > yyyy-mm-dd format. I've decided to set it up to ask for user input. > > What I need is some input on is how to make it create the array for all the > dates requested. For instance, if someone wants to run the script spanning > 07/20/2007 to 08/20/2007 how can I split that up to ensure it runs across all > days and both months?
The POSIX strftime() function has no problem taking values for the day that exceed the actual number of days in the given month. When it is given such a value, it automatically increments the month and/or year appropriately: $ perl -MPOSIX=strftime -e' my $start = "07-20-2007"; my $end = "08-20-2007"; my ($m, $d, $y) = split /-/, $start; my $date; do { $date = strftime("%m-%d-%Y", 0, 0, 12, $d, $m - 1, $y - 1900); print "$date\n"; $d++; } until ($date eq $end); ' Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/