I'm having a problem trying to get a regular expression to
work for checking a long password. The long password consist
of an access code plus any combination of numbers, upper or
lower case letters, or the underscore(_). The total length of the long password must be at least 5 characters and cannot exceed 16 characters. The regular expression I use below doesn't seem to work. Can someone tell me what I'm doing wrong. Knowing me it's probably something simple. Thanks in advance for your help.
#!/usr/local/bin/perl -w
use strict; # enforce declarations and quoting
use diagnostics; # hints for errors
my $acode = "1234";
print "Type in your long password\n";
my $lngpswd = <STDIN>;
chomp($lngpswd);
print "\$lngpswd = $lngpswd\n";
my $result = $lngpswd =~ /^$acode\w{5,16}/ ? "OK" : "NO";
print "\$result = $result\n";
if ( $result eq "OK" )
{
print "$lngpswd is a good long password\n";
}
else
{
print "$lngpswd is an invalid Long Password!\n";
}
work for checking a long password. The long password consist
of an access code plus any combination of numbers, upper or
lower case letters, or the underscore(_). The total length of the long password must be at least 5 characters and cannot exceed 16 characters. The regular expression I use below doesn't seem to work. Can someone tell me what I'm doing wrong. Knowing me it's probably something simple. Thanks in advance for your help.
#!/usr/local/bin/perl -w
use strict; # enforce declarations and quoting
use diagnostics; # hints for errors
my $acode = "1234";
print "Type in your long password\n";
my $lngpswd = <STDIN>;
chomp($lngpswd);
print "\$lngpswd = $lngpswd\n";
my $result = $lngpswd =~ /^$acode\w{5,16}/ ? "OK" : "NO";
print "\$result = $result\n";
if ( $result eq "OK" )
{
print "$lngpswd is a good long password\n";
}
else
{
print "$lngpswd is an invalid Long Password!\n";
}