my @letters = split //, $pass; # get the letters into # an array my %lc = (); # initialize a hash for use in a count. foreach my $letter (@letters) { $lc{$letter}++; # count the occurrence of each letter } my @keys = keys %lc; get the individual characters used. if (($#keys+1)/length($foo) < .6) { # if there are less than 60% unique characters print "not enough different letters\n"; } my $ok = 1; # just a flag foreach my $key (@keys) { # check the frequency of individual letters. # if a character occurs more than 20% of the time, it is # no good. # an alternate way to do this would be to check the actual # occurrences of each character: # $ok = 0 if ($lc{$key} >= 2); $ok = 0 if ($lc{$key}/length($foo) > .2) } print "You have to have more different letters." unless $ok;