use strict; use POSIX qw(strftime); my $filename = strftime "foo.%Y%m%d-%H%M%S.txt", localtime; print "A good filename could be '$filename'"