On 24/03/10 00:13 -0700, Bruce Ferrell wrote:
if ( ! defined $username || ! $username =~ /[0-9]{10,11}/ ) {
do something;
} else {
do something else;
}
what that's supposed to do is this:
if it's blank or not 10 or 11 digits...
The question is where is my understanding faulty or did I mess up.
I hope I understood you right now; I think you want the !~ operator.
my $user1 = 'foobar';
my $user2 = '10100101011';
if(!defined($user1) || $user1 !~ /[0-9]{10,11}/) {
print "User 1 $user1 is not legal\n";
}
else {
print "$user2 is legal";
}
if(!defined($user2) || $user2 !~ /[0-9]{10,11}/) {
print "User 2 $user2 is not legal\n";
}
else {
print "$user2 is legal\n";
}
----
» perl 1.pl
User 1 foobar is not legal
10100101011 is legal
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/