On 2007/03/15, at 18:29, Jenda Krynicky wrote:
From: Igor Sutton Lopes <[EMAIL PROTECTED]>
<code>
my @possible_values = qw{
http://www.google.com
https://my.domain.
http://some.other.domain.net
};
my @urls = qw{
http://www.google.com/?some_bizarre_args
https://my.domain.com
https://my.domain.net
http://some.other.domain.net
};
my $regex = '(' . join( "|", @possible_values ) . ')';
foreach my $url (@urls) {
if ( $url =~ /$regex/ ) {
print "$url matches!\n";
}
}
</code>
Try to match a URL like this:
http://wwwXgoogle.com/?some_bizarre_args
It matches, doesn't it? Bummer.
Try
my $regex = '(' . join( "|", map quotemeta($_), @possible_values ) .
')';
instead. Plus you may want to make the match case insensitive. Host
names ARE case insensitive.
You are totally right, sorry for pay no attention to that detail.
--
Igor Sutton
[EMAIL PROTECTED]