Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

RE: Parsing File Timestamp?

by tenatious (Beadle)
on Aug 26, 2000 at 22:30 UTC ( #29825=note: print w/replies, xml ) Need Help??


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";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://29825]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2022-10-06 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (26 votes). Check out past polls.

    Notices?