Like the other two have said, you could always use use Time::HiRes 'time';, instead of having to sleep. I recently ran into this same problem with a CGI file uploader (used the localtime() as a unique key and allowed 4 uploads at a time; which without saying, most of the time the files used the same key and overwrote the others).
sleep may not be the best choice but I don't see anything other than time as a setback. Just keep in mind you're sleeping after each loop and a sleep 5; will surely take forever if you have a 10,000 item array!
It's a safe method to ensure unique ID's, I still use this over use Time::HiRes 'time';.
Good luck.
"Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"
sulfericacid