Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Date in filename

by dsb (Chaplain)
on Jul 25, 2001 at 00:41 UTC ( #99474=note: print w/replies, xml ) Need Help??


in reply to Date in filename

If you are worried about uniqueness in the filename, you are probably better of using the UNIX timestamp.
$file = time() . "whatever.ext";
The time function returns the UNIX time in seconds since the epoch. Using this method also prevents spaces from being in the filename that would be there if you used localtime.

Might want to take a look at perlfunc.

Amel - f.k.a. - kel

Replies are listed 'Best First'.
Re: Re: Date in filename
by alfie (Pilgrim) on Jul 25, 2001 at 17:19 UTC
    If you are really searching for a uniqe filename, you should quite propably add $$ (the process-ID) to it, to be on the save side. So you can have multiple programs running at the same time that do not interfere:
    $file = time()."-$$.tmp";
    HTH!
    --
    use signature; signature(" So long\nAlfie");
Re: Re: Date in filename
by Anonymous Monk on Jul 25, 2001 at 17:06 UTC
    Thanks Amel. This is actually better than what I wanted. I'm gonna use it!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-05-28 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (99 votes). Check out past polls.

    Notices?