#!/usr/local/bin/perl5.8.0 use strict; use warnings; use Getopt::Long; my $length = 8; GetOptions ( "length=i", \$length); our @CHARS = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9, split //, q{!@#$%^&*()-=_+[]{}|;':",./<>?`~} ); my $pw; foreach (1..$length) { $pw .= $CHARS[ rand @CHARS ]; } print $pw,"\n";