i am new to perl and using regex. I have a subroutine that is suppose to show that we are looking for a pattern that has one of more dots".". The next line is to use this subroutine to check if there are dots in some patterns. However I find that the if block in my if/else statement is not evaluated, it only evaluates the else block.
my $hostname1 = "hh.uu"
my $hostname2 = "yyhu"
sub isDotted {
return 1 if $_ = ~/\./g; return 0;
}
if (isDotted(hostname1) != isDotted(hostname2))
{
print "Must be equal";
exit;
else {
print "Perfect good to go";
}
This code prints out "Perfect good to go" and the fact that $hostname2 does not have a dot "." in it.
Aucun commentaire:
Enregistrer un commentaire