Quick actions

cmd+k|ctrl+k

Navigation

Languages

Password Check

Snippet info

Language

Perl

Visibility

public

Author

hsins

Created

2019-01-03T10:08:33Z

Updated

2019-01-03T10:08:33Z

#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;

while (<>) {
    chomp;
    &passwordCheck;
}

sub passwordCheck {
    if (m%
        ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{8,11}$  |
        ^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W).{12,15}$ |
        ^(?=.*[a-z])(?=.*[A-Z]).{16,19}$                 |
        ^.{20,}$
    %x) {
        print "The password \"" . $_ . "\" is valid.\n";
    } else {
        print "The password \"" . $_ . "\" is invalid.\n";
    }
}
INFO