# this takes the 4th through sixth elements of the array # returned by localtime and sets @times to them my @times = (localtime)[3..5]; my $date = sprintf("%4d%02d%02d", $times[2]+1900, $times[1]+1, $times[0]);