![](https://surniaulula.com/wp-content/uploads/2014/03/perl-camel-300x300.png)
Here’s a script I keep in ~/bin/randpwd.pl and use frequently to generate random password strings. It prints an 8 character password by default, but you can also specify a different password length on the command line. I left out the capital letter “o” to avoid confusion with the number zero. ;-)
#!/usr/bin/perl -w
# /usr/local/bin/randpwd.pl {length}
# Generate a random password.
# by Jean-Sebastien Morisset (https://surniaulula.com/)
use strict;
my @chrs = ( 'A'..'N', 'P'..'Z', 'a'..'z', 0..9 );
my $len = defined( $ARGV[0] ) ? int( $ARGV[0] ) : 8;
print $chrs[rand @chrs] for 1 .. $len;
print "\n";
exit 0;