Script for generating random strings
Neat Perl snippet to generate a string of random characters, for, say, randomized usernames, passwords, etc.:
sub random_string {
my $p = '';
foreach (1..$stringlength) {
$p .= chr($chars[rand($#chars)]);
}
return $p;
}
# List of valid ascii characters, by decimal number
# numbers, capital letters, lowercase letters
@chars = (48..57,65..90,97..122);
An ascii chart can be found here.