in reply to Using localtime() as a unique identifier

I'm not sure I understand the question. The time is determined when the function is called. In this case, I'm not sure it matters — if your localtime has a one second granularity (and I consider that fairly likely), it's likely that you'll whack the first three images.

Something like Time::HiRes would be much better in this case.