Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Password Validation
#perl 5.22.1 # Write a Perl function that takes in a password and checks whether it's valid. The password should follow the following rule: # Passwords must be at least 8 characters long. # Between 8-11: requires mixed case letters, numbers and symbols # Between 12-15: requires mixed case letters and numbers # Between 16-19: requires mixed case letters # 20+: any characters desired sub pwdChk{ my ($pwd) = @_; my $len = length($pwd); print "\nlength = $len"; my $ret = "invalid"; if($len < 8){ $ret = "invalid"; }elsif($len < 12){ if($pwd =~ /\d/ && $pwd =~ /[a-z]/ && $pwd =~ /[A-Z]/ && $pwd =~ /[^A-Za-z0-9]/){ $ret = "valid"; } }elsif($len < 16){ if($pwd =~ /\d/ && $pwd =~ /[a-z]/ && $pwd =~ /[A-Z]/){ $ret = "valid"; } }elsif($len < 20){ if($pwd =~ /[a-z]/ && $pwd =~ /[A-Z]/){ $ret = "valid"; } }else{ $ret = "valid"; } return $ret; } my$pwd = <STDIN>; my$res = pwdChk($pwd); print "\n$pwd is $res";
run
|
edit
|
history
|
help
0
FOP utilities
palindromic dates
Updated Safe 2.1 Solution
Array_with_join_function
Soumya 101758
Jeffy John Sam (101724)
doctor
Array_with_shift_function
Challenge 41 Task 1
Supriya