I like to use Time::HiRes time() and s/.// to get a long unique number. You dont have to worry about file locking (to prevent clobbering if multiple instances try to get a number at the same time).
-Waswas | [reply] |
You could always query the table to find out how many rows it has, then start to insert with $numRows + 1 as your first unique key, incrementing this variable for each row thereafter.
That'd work as long as you're not threading, or running multiple instances of the script at the same time.
Hope that helps .. --Foxcub | [reply] [d/l] |
carefull with this....
if you start deleting rows, ($numRows + 1) wont guarantee uniqueness.
if you choose to do the config file way- take a look around here for some good file locking examples.
here's the file locking tutorial.
| [reply] [d/l] |