Toxa has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Password validation
by radiantmatrix (Parson) on Sep 15, 2005 at 21:17 UTC

    I suggest Data::Password which will give you a true/false on whether a password is good or not. The defaults are good for general purposes, but all of the types of validation are configurable.

    As for your direct question, no your set won't work. There are two steps you need to take, if you choose not to use a module (though I highly recommend module use). First, make sure there are no *invalid* chars in the password, then make sure you have minimums of your various requirements. In your case:

    $passed_tests = 0; $string =~ /^[\x20-\x7E]+$/ and $passed_tests++; #only printable chars $string =~ /[^a-zA-Z]/ and $passed_tests++; #>=1 char that isn't +a letter if ($passed_tests == 2) { print 'validated'; } else { print 'validation failed'; }
    <-radiant.matrix->
    Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
    The Code that can be seen is not the true Code
    "In any sufficiently large group of people, most are idiots" - Kaa's Law
Re: Password validation
by McDarren (Abbot) on Sep 15, 2005 at 14:28 UTC

    A simple search on CPAN returns dozens of possibilities.

    I can't comment on or recommend any particular module, as I've not used any of them myself. However, I would recommend using a module rather than trying to pre-cook your own regular expression - why re-invent the wheel?

    --Darren