http://qs321.pair.com?node_id=510347


in reply to converting from php

Here is a sample script that shows how to do this using the DateTime module. There are probably shorter ways of doing the same thing, but this shows you a small bit of the power of the DateTime module, which can do pretty much anything you ever want to do with dates.

#!/usr/bin/perl use strict; use warnings; use DateTime; use DateTime::Format::Strptime; my $formatter = DateTime::Format::Strptime->new( pattern => '%a, %d %b %Y' ); my $today = DateTime->now( formatter => $formatter ); my @days = (); foreach my $day (1..14) { push @days, $today->clone->add( days => $day ); } print join("\n", @days), "\n";