in reply to genpass Password Generator

Very clear, well thought out, and quite readable ++ no problem. Just a tad on the verbose side (using string comparisons where numeric comparisons will do, using more complicated conditions where simpler ones will do, using an unnecessary counter variable to track the size of an array, trivial nit-picky things of that sort).

There would be a lot less code to do the same thing if you start with a string that has all characters available for use in passwords, then remove classes of characters according to the given options:

my $pswd_chars = join( '', map {chr} ( 0x21 .. 0x7e )); $pswd_chars =~ s/\d+// if ( $numbers ); $pswd_chars =~ s/[A-Z]+// if ( $uppercase ); $pswd_chars =~ s/[a-z]+// if ( $lowercase ); $pswd_chars =~ s/[_\W]+//g if ( $symbols ); if ( length( $pswd_chars ) == 0 ) { push @errmsg, "\n *** You eliminated all possible characters."; }
(update: added a couple of missing "+" to the regexen)

Also, if someone wants to use this to create passwords to be handed out to clients (i.e. via email or web transactions), another useful option would be to eliminate confusable characters:

$pswd_chars =~ tr/1Il0O//d if ( $confusable );
As for random selection based on the remaining characters:
sub GenPass { my ( $pswd_chars, $pswd_len ) = @_; my $limit = length( $pswd_chars ); my $pswd = ''; for ( 0..$pswd_len-1 ) { $pswd .= substr( $pswd_chars, rand( $limit ), 1 ); } return $pswd; }
Last suggestion: definitely check out POD, and Pod::Usage -- you'll fall in love with that.