bt707
asked on
Perl - check names in varible
I have an issue where I need up update our password checker so that when a user resets their password a check is made to make sure the new password does not contain the users First or Last name.
I have a sample script for a check below, the issue I have is that we have many users that has multiple names in their First or Last name, so in the sample below the check would work if I changed the Fist or Last name to just one word.
How can I fix the check to break down the multiple names in the First or Last name (if exists) then do the test on each of the words in the Fist or Last name.
I have a sample script for a check below, the issue I have is that we have many users that has multiple names in their First or Last name, so in the sample below the check would work if I changed the Fist or Last name to just one word.
How can I fix the check to break down the multiple names in the First or Last name (if exists) then do the test on each of the words in the Fist or Last name.
#! /usr/bin/perl
use strict;
use warnings;
my $newPassword = 'Billy#123';
my $firstName = 'John Doe';
my $lastName = 'Billy Ray';
my @wordsInNames;
push(@wordsInNames, "$firstName", "$lastName");
foreach my $wd (@wordsInNames) {
if ($newPassword =~ /$wd/) {
print "Found name in password: $wd\n";
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
How many ways to skin a cat! I wish I hadn't delayed to test mine!
ASKER
Thanks for all the quick answers, I had tried the one from wilcoxon when posted and worked fine, I'm sure all other did the same, just was not sure how to spit the names for the checks.
Thanks All !!!!
Thanks All !!!!