Prefetch Technologies // Keeping your cache lines cozy

Generating random passwords with Perl

While performing some house cleaning this evening, I came across the following Perl nugget:

#!/usr/bin/perl

my @alphanumeric = ('a'..'z', 'A'..'Z', 0..9);
my $randpassword = join '', map $alphanumeric[rand @alphanumeric], 0..8;
print "$randpasswordn"

This awesome little 3-line script will produce random 8-character alphanumeric passwords:

$ randpasswd.pl
ahvtGRE6U
$ randpasswd.pl
lxVLA7xLv

I wish I knew where I grabbed this from so I could publicly thank the author.