Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re (tilly) 1: create file with current date for name

by tilly (Archbishop)
on Aug 07, 2001 at 22:31 UTC ( [id://102870]=note: print w/replies, xml ) Need Help??


in reply to create file with current date for name

A random note. Barring specific functions to do it for you, I like constructing yyyymmdd format through a numerical operation, not a sprintf.
# Takes the time in seconds as an optional argument. # Returns the local date in yyyymmdd format. sub local_yyyymmdd { my $time = shift || time(); my ($year, $month, $mday) = (localtime($time))[5,4,3]; return 10_000*($year + 1900) + 100*($month + 1) + $mday; }
Why? Because I have met many languages without a sprintf, but none without arithmetic. And sure, it may be ugly, but that is why Larry gave us functions...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-28 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found