Looks like you could be writing a script for password validation. Don't know if this will help, but I recently used this for password validation(1 letter, 1 number, 1 symbol(!@#$%^&*()?).
if(($new_password !~ /\d/) || ($new_password !~ /[a-zA-Z]/) ||
($new_password !~ /\W/) || (length($new_password) < 6)){
...BAD PASSWORD...
{