I need a string that is random. It must have 2 characters followed by 6 digits. I'm currently using the following code:
$randlet =~ tr/a-z/A-Z/;
$randnum = 100000 + int(rand(999999));
$randid = $randlet . $randnum;
Can anyone spot any faults with the above code? Any way to better that code? It works fine at the moment. Just unsure of the method used to ensure the length of random numbers to be 6 digits long.
Rgds
Wil
- wil
Code:
$randlet = chr(int(rand(20)) + 99) . chr(int(rand(20)) + 99); $randlet =~ tr/a-z/A-Z/;
$randnum = 100000 + int(rand(999999));
$randid = $randlet . $randnum;
Can anyone spot any faults with the above code? Any way to better that code? It works fine at the moment. Just unsure of the method used to ensure the length of random numbers to be 6 digits long.
Rgds
Wil
- wil