Time::Piece is the main:
use Time::Piece; use Time::Seconds qw(ONE_DAY); my $yesterday = localtime() - ONE_DAY(); print $yesterday->strftime('%d%m%y'), "\n";
If you are concerned about daylight saving time, you can normalize the current time until noon:
use Time::Piece; use Time::Seconds qw(ONE_DAY ONE_HOUR); my $today = localtime; my $yesterday = $today + ONE_HOUR * ( 12 - $today->hour ) - ONE_DAY; print $yesterday->strftime("%d%m%y"), "\n";
If you can live with dependencies, use DateTime :
use DateTime; print DateTime->now->subtract(days => 1)->strftime('%d%m%y'), "\n";
source share