> > regex.
> > if ( m/^https?\/\/:blah\.com/)
>
> <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.
Thanks Jenda. I ended up going with this:
if ($Scratch->{url} =~ /^https?:\/\/images\.google\./) {
Does that look OK?
- Grant
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/