On Jul 22, dan said:
the wildcard search could be anything like an exact match with no wildcards
in, or a proper wildcarded search. such as:
*.co.uk
someones.hostname.com
Do you plan on allowing the '?' wildcard to match any single character?
Just curious how robust this should be.
sub wcmhost {
$temp1 = shift;
$temp2 = shift;
($temp1 = quotemeta $temp1) =~ s/\\\*/.*/g;
I would instead say:
$temp1 =~ s{([^\w\s])}{
if ($1 eq '*') { '.*' }
else { "\\$1" }
}eg;
I believe that's somewhat safer.
if ($temp2 =~ $temp1) { return 1; }
else { return 0; }
You want to anchor the regex with ^ and $:
if ($temp2 =~ /^$temp1$/) { return 1 }
else { return 0 }
And while we're at it, you could just write:
return $temp2 =~ /^$temp1$/;
}
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>