use warnings; use strict; my ( $day, $month, $year ) = (localtime)[ 3 .. 5 ]; print sprintf "%s : %s : %s\n", $day, $month + 1, $year + 1900, $/; #OR use POSIX qw(strftime); print strftime "%d - %m - %Y\n", localtime; #OR use Time::localtime; my $tm = localtime; my $day = $tm->mday(); my $month = $tm->mon() + 1; my $year = $tm->year() + 1900; print sprintf "%s \\ %s \\ %s", $day, $month, $year;