.------[ Tom Allison wrote (2002/11/14 at 09:45:42) ]------
|
| How can create a random string, similar to MD5 hash, but with a
| much smaller number of characters? Maybe 8 characters..
|
`-------------------------------------------------
Here is one idea:
my @letters = ('a' ... 'z', 'A' ... 'Z');
my $str = '';
for ( 1 ... 8 ) {
my $num = int(rand($#letters));
$str .= $letters[$num];
}
print "Random string: $str\n";
You can also add other characters you'd like to have available to
the @letters array such as symbols, numbers, etc. You can adjust the
length by changing the for ( 1 ... 8 ) to say for ( 1 ... 10 ) to
make it 10 characters long.
---------------------------------
Frank Wiles <[EMAIL PROTECTED]>
http://frank.wiles.org
---------------------------------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]