my ( $yr, $mo, $dy ) = (localtime)[5,4,3]; my $outfile = sprintf( "%04d%02d%02d.txt",$yr+1900,$mo+1,$dy ); # (I tend to format date-as-filename so that it will be # easy to sort file names chronologically: YYYYMMDD) # you can add hours and minutes, if you like -- check # `perldoc -f localtime`...