No such thing as a small change | |
PerlMonks |
Re^3: Unique filenames with Time::HiResby mhi (Friar) |
on Jul 19, 2004 at 10:01 UTC ( [id://375508]=note: print w/replies, xml ) | Need Help?? |
Cycling through all the PIDs within a second (or whatever is the smallest increment of time you can get) is not the problem. Hitting that cycle in one of those itervals is. And it will happen. So what you need to do for your exception handling is to first determine how high the process counter on your machine can count (this may possibly change with OS updates, so I'd try to get that information dynamically from the OS). Then decide that if there is a difference of for examle at least half that maximum count between PIDs in your filenames, the lower block of them came after the higher block. Process them accordingly That should do ya. Update: grinder has /msged me that this will not work on BSD type boxes where random PID allocation (a security feature) has been configured. He's probably right, so you better talk to your admin before relying on consecutive PID allocation for the next couple of years. :-)
In Section
Seekers of Perl Wisdom
|
|