Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Handling elements of an array of array references, where the function calls for an array?

by Perlbotics (Canon)
on May 14, 2012 at 22:03 UTC ( #970521=note: print w/ replies, xml ) Need Help??


in reply to Handling elements of an array of array references, where the function calls for an array?

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... ;-)


Comment on Re: Handling elements of an array of array references, where the function calls for an array?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2015-07-28 23:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls