hey all,

Scratchin' my head on this one for a couple of hours now, looking at camels. sheep and 
other documentation creatures to no avail.  I'm trying to match a pattern that's 
already (must be) in a variable like so:

$var = "coyote";
while (<FILE>) {
  if ($_ =~ /$var/i) {
    print $_ . " matches\n";
    };
  };

great - this works until I come to 

$var = "Wile E. Coyote";

and fails to match.  Is there a way to do this?

        Why do you say it fails. Here is a small script which mataches:

use strict;

my $var = "Wile E. Coyote";
while (<DATA>) {
  chomp;
  
  if ($_ =~ /\Q$var\E/i) {  # should use \Q \E to tell the regex to not use any of the 
special characters w/in
                                    # the regex.  The . would be allow E? as a hit: 
Wile E? Coyote.
    print $_ . " matches\n";
    };
  };

__DATA__
The Coyote was here.
He is not here!!
Returns the coyote.
Then Wile E. Coyote returns here.

tia,
Glen
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


**********************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
****************************************************************


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to