in reply to date arithmetic

At the moment I am using the DateTime-Module but I just reinstalled it on a new system and I am shocked on how much dependencies it pulls in.

Yes, DateTime is heavy but very full-featured. It is a trade-off (as is usual).

Luckily Time::Piece is in core and is almost a drop-in replacement for your simple script. I might not write it this way from scratch but have kept your method to show how analogous the two modules are.

#!/usr/bin/env perl use strict; use warnings; use Time::Piece; use Time::Seconds; my $td = localtime; my $days_since_friday = ($td->day_of_week - 5) % 7; my $days_to_subtract = $days_since_friday == 6 ? -1 : $days_since_frid +ay; $td -= $days_to_subtract * ONE_DAY; print $td->strftime("%d%m%y");

Replies are listed 'Best First'.
Re^2: date arithmetic
by Perl300 (Friar) on Apr 02, 2018 at 16:28 UTC
    I was looking for something similar and this worked perfect for me. Thank you hippo.