http://www.perlmonks.org?node_id=29825


in reply to Parsing File Timestamp?

If I understand you correctly, you want to place a timestamp at the end of the filename. I'd advise against this because it prevents some machines from associating the file to an extension. Instead build the filename and place the timestamp in a location where you can easily get at it. e.g.
# read info # and then we are ready to build our filename # unless you are writing binary data, the following should # do the trick. $time = time; $filename="myfile_".$time.".txt"; # (and then just print using $filename)

time will give a machine-readable time in seconds from the epoch. It should be a valid way of doing things until around 2030. Hopefully, by then we won't have computers :)

If the time needs to be readable by a human, you can do something like:

$time = scalar localtime; $time =~ tr/ /_/; #get rid of the spaces; $filename = "myfile-".$time.".txt";