hi
i have a bit of a puzzling question. well, puzzling to me anyway.
i have a sub which is passed 2 arguments. a wildcard search, and an actual
string to search in.
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
etc and it has to search through a list of hosts and return only the ones
that match the search string supplied.

the sub i have is:
sub wcmhost {
    $temp1 = shift;
    $temp2 = shift;
    ($temp1 = quotemeta $temp1) =~ s/\\\*/.*/g;
    if ($temp2 =~ $temp1) { return 1; }
    else { return 0; }
}
whereas this is all very well, but if i search for *.uk, it won't just
return hostnames ending in ".uk", but it will return a host such as
"this.is.my.ukhostname.net", matching the ".uk" inside it too. what
modifications do i need to make to this sub so it only matches what's given,
and wildcards where there's a *?
temp1 is the search string, temp2 is the actual string it has to search in.
the sub is called from within a foreach loop which loops through a list of
hostnames, and responds according to the 1 or 0 this sub returns.

thanks for all your help,

dan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to