in reply to Re^8: Renaming an image file
in thread Renaming an image file
Well, okay. But all you've done is move the goal posts a little.
Webservers are inherently multitasking, so adding all those digits of date and time is pretty useless as there could be many uploads completing within each given second.
And depending upon the quality of your rand() function, the rand(10000) bit does almost nothing:
perl -E" $t=time; ++$h{ rand(10000) } while time()==$t; my $n=0; $_ > 1 and $n+=$_ for values %h; say $n, ' duplicates in 1 second'; " 13793 duplicates in 1 second perl -E"$t=time; ++$h{ rand(10000) } while time()==$t; my $n=0; $_ > 1 + and $n+=$_ for values %h; say $n, ' duplicates in 1 second';" 400896 duplicates in 1 second >perl -E"$t=time; ++$h{ rand(10000) } while time()==$t; my $n=0; $_ > +1 and $n+=$_ for values %h; say $n, ' duplicates in 1 second';" 504998 duplicates in 1 second
Even with what is probably the best PRNG available, you can still generate duplicates:
c:\test>perl -MMath::Random::MT=rand -E"$t=time; 1 while time==$t; ++$ +h{ rand(10000) } while time()==$t+1; my $n=0; $_ > 1 and $n+=$_ for v +alues %h; say $n, ' duplicates in 1 second';" 4 duplicates in 1 second c:\test>perl -MMath::Random::MT=rand -E"$t=time; 1 while time==$t; ++$ +h{ rand(10000) } while time()==$t+1; my $n=0; $_ > 1 and $n+=$_ for v +alues %h; say $n, ' duplicates in 1 second';" 4 duplicates in 1 second >perl -MMath::Random::MT=rand -E" $t=time; 1 while time==$t; ++$h{ rand(10000) } while time()==$t+1; my $n=0; $_ > 1 and $n+=$_ for values %h; say $n, ' duplicates in 1 second'; " 6 duplicates in 1 second
It takes only a few milliseconds to read and md5 the contents of a medium sized image file.
|
|---|