jlwoodruff has asked for the wisdom of the Perl Monks concerning the following question:
Hello guys and I am very appreciative to anyone whom might can give some direction on how to handle a current situation that I am dealing with. Please allow me to explain the best way that I can. I have a script that automatically assigns a number by excuting this code:
my $range = 200; my $minimum = 1000000000; my $jobNum = int(rand($range)) + $minimum;
When the value is assigned to $jobNum then I need to go an extra step in determining that the number has never been previously used. Of course, with a range that I have chosen, most likely it won't occur, but you can't assume either. The previously used $jobNum(s) reside in a file called aj.db which is a basic text file that the data is held in from html forms, with | separators. I want to be able to search this file by opening it temporary (within the running script), search for the randomly assigned String, that is assigned at that moment, against the previously assigned Strings within the aj.db database file. <If> the String cannot be found then allow the current randomly assigned String to be used. Of course, if the String of numbers have been used before, then loop back to get a new random number and check again until one is found that has not been used. I'm sure there is a simple solution for this but I have not found none yet and cannot understand fully how this can be done. I have no current code to present in my testing to see if I can do this on my own. If anything, point me toward some ideas that i can try so I might achieve this own my own. Again, any help would be appreciated.
Thank you
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Testing numeric strings
by toolic (Bishop) on Jul 20, 2011 at 18:15 UTC | |
by jlwoodruff (Initiate) on Jul 20, 2011 at 18:58 UTC | |
|
Re: Testing numeric strings
by jethro (Monsignor) on Jul 20, 2011 at 18:36 UTC | |
|
Re: Testing numeric strings
by onelesd (Pilgrim) on Jul 20, 2011 at 18:38 UTC | |
by jlwoodruff (Initiate) on Jul 20, 2011 at 19:19 UTC | |
by Anonymous Monk on Jul 20, 2011 at 23:03 UTC | |
|
Re: Testing numeric strings
by zek152 (Pilgrim) on Jul 20, 2011 at 20:54 UTC |