In my script I need to make a cycle like this one:
use DateTime;
for $j(0..3){
my ($date) = DateTime->now->ymd;
my ($k) = 0;
while($k <= $j){
$date = ($date->subtract( days => 7));
$k++;
}
print "$date\n";
}
which should get the current date, then one week ago, etc. Sadly, after getting the correct current date, it doesn't work and I don't know what's wrong.
Error message is "Can't call method "subtract" without a package or object reference [...]",
but I have no idea how to fix this.
If possible, I'd like to keep using DateTime only OR replacing it with another module (possibly no more than one).