Sinister variable caching problem with rand()

2010-05-15 Thread Anthony Esposito
In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variable $idNum was keeping the same random string for multiple executions. I created a test program to demo

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Perrin Harkins
On Sat, May 15, 2010 at 4:03 PM, Anthony Esposito wrote: > In one of my programs I started to receive database errors for not having a > unique id. I generate unique ids for each of the mysql lines that I add to > the database. I realized that the perl variable $idNum was keeping the same > random

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Adam Prime
Perrin Harkins wrote: On Sat, May 15, 2010 at 4:03 PM, Anthony Esposito wrote: In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variable $idNum was keepin

Re: Sinister variable caching problem with rand()

2010-05-15 Thread André Warnier
Adam Prime wrote: Perrin Harkins wrote: On Sat, May 15, 2010 at 4:03 PM, Anthony Esposito wrote: In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variab

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Cosimo Streppone
On Sat, 15 May 2010 22:03:50 +0200, Anthony Esposito wrote: In one of my programs I started to receive database errors for not having a unique id. I generate unique ids for each of the mysql lines that I add to the database. I realized that the perl variable $idNum was keeping the same r

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Michael Peters
On 05/15/2010 04:47 PM, André Warnier wrote: A tip : to get a really unique identifier Another tip: to get a really unique identifier use mod_unique_id or Data::UUID or the UUID() function in mysql. -- Michael Peters Plus Three, LP

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Anthony Esposito
Thank you everyone for helping me, I am surprised by the support our there for mod_perl. Cosimo sent me a quick fix to add to the startup.pl file, I have tested and verified it. The code below works with no problems after adding: my $srv = Apache2::ServerUtil->server; $srv->push_handlers( PerlC

Re: Sinister variable caching problem with rand()

2010-05-15 Thread Anthony Esposito
PS. I had to strengthen the srand() function I added to the startup.pl that Cosimo suggested. I used the example from the perldoc and have not had any duplicate keys so far. I was having upwards of 3 per 1000 when using srand(time ^ $$) Fix added to startup.pl file ---