Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by tilly (Archbishop)
on Aug 07, 2001 at 22:31 UTC ( #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...


Comment on Re (tilly) 1: create file with current date for name
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-11-27 06:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (180 votes), past polls