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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.