if( $usedpw =~ m/$pw/ ){ #actaully this inverses yourlogic print "Your unique password is: $pw\n"; }