use strict; use warnings; my ( $day, $month, $year ) = (localtime)[3,4,5]; my $date = sprintf "%.04d%.02d%.02d", $year + 1900, $month + 1, $day;