AM gave you a valuable hint about shuffling and I second mbethke's suggestion on rather testing the user provided password with an appropriate password checker.
Despite the security issues, here's a hint to you Perl problem using your original code with some annotations and corrections:
#!/usr/bin/perl use strict; use warnings; my @chars = ( "a" .. "k", "m","n", "p" .. "z"); my @upchars = ("A".."N","P".."Z"); # <-- NOTE: "P..Z" -> "P".."Z" my @nona = qw(! @ $ % & ( ) + = { } [ ] < > ~); my @nums = (0 .. 9); my $lc = \@chars; my $uc = \@upchars; my $na = \@nona; my $nu = \@nums; my @types = ($lc, $uc, $na, $nu); # compact: my @types = (\@chars +, \@upchars, ... my $a = join("", @{$types[3]}[ map { rand @{$types[3]} } ( 1 .. 4 ) ] +); $a .= join("", @{$types[2]}[ map { rand @{$types[2]} } ( 1 .. 4 ) ] +); $a .= join("", @{$types[1]}[ map { rand @{$types[1]} } ( 1 .. 4 ) ] +); $a .= join("", @{$types[0]}[ map { rand @{$types[0]} } ( 1 .. 4 ) ] +); # ^--deref/arrayslice ^-- deref for number of el +ements # nobody complained about using '$a' yet, so I don't do either ;-) print "My selection is $a \n"; # you should shuffle and shorten the result exit; __DATA__ My selection is 0548)~}+QRVKzkkt My selection is 7922&)(&AAZZwiaw My selection is 5263+!@>VXXBaezt
Enforcing someone to use e.g. 0548)~}+QRVKzkkt as a password just increases post-it sales... ;-)
In reply to Re: Handling elements of an array of array references, where the function calls for an array?
by Perlbotics
in thread Handling elements of an array of array references, where the function calls for an array?
by desertrat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |