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
|