Hi Monks,
I have a Perl script that uses the time() fuction to create a (hopefully) unique ID (not the greatest method I realise). However when in a loop and creating ID automatically my program can sometimes run a little too fast and the ID's created are the same. I therefore want to add a little delay of say 5 seconds, inbetween each run of the loop. Is this really bad Perl practise? How can I do this? I thought about this method, but just wanted to check with you guys.
foreach (@loop) { my $id=time(); print $id; sleep 5; }
Any idea's if this will work? This is of course a simplified version of my program just as an example.
Cheers,
Tom
janitored by ybiC: Retitle from "sleeping a script", to improve future searchability
In reply to Use time() to create unique ID by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |