# Build arrays of vowels and consonants my @vowels = qw( a e i o u y ); my %vowels = map { $_ => 1 } @vowels; my @consns = grep { ! $vowels{$_} } ( 'a' .. 'z' ); # Also include uppercase letters push @vowels, map uc, @vowels; push @consns, map uc, @consns; # subroutine to pick a random entry from an array sub pick_one { my $array_ref = shift; return $array_ref->[ int rand( @$array_ref ) ]; } # Define a pattern of "CVCVC" my @syntax = ( \@consns, \@vowels, \@consns, \@vowels, \@consns ); # Do this part each time you need a new password foreach ( 1 .. 10 ) { # Generate a random psuedo-word my $word = join '', map { pick_one( $_ ) } @syntax; # Then do something with it... print "$word\n"; }