Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: "unique" filename?

by 2501 (Pilgrim)
on Dec 03, 2000 at 20:05 UTC ( [id://44706]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to "unique" filename?

how about the following:
$filename = $$.time;
This is a combination of process ID and time. This would prevent duplicate file names from being a possibility.

Replies are listed 'Best First'.
Re: Re: "unique" filename?
by myocom (Deacon) on Dec 03, 2000 at 21:18 UTC
    Actually, that wouldn't prevent duplicate filenames at all, depending on how fast you're generating filenames. For example, look what the following does:
    while (1) { print $$.time."\n"; }

    Also, on Win32, there's a non-zero chance of a PID being reused.
      When you log into a site, you have two options.
      You can start running a script from a new connection or you can use an existing connection.
      Since only one person can be using a PID at a time, the combination of time and PID is fine.

        That might be so, but if you need the file to remain on the server for a while (as part of session management perhaps), then your method breaks.

        With some operating systems, for instance OpenBSD, there is a chance that the same PID will occur twice within one second, especially on a heavily loaded site. You are also at risk of exposing your machines current position in the PID list, which could be of use to someone hoping to exploit the way someone has used the PID and time to seed a random number generator.

        Use the modules, and you insulate yourself from these problems. CPAN is your friend.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://44706]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.