Hi, Pandey Rajeev-A19514 [mailto:[EMAIL PROTECTED] asked: > I have a question regarding matching strings that have > embeded perl special characters. > > $abc = 'MC10.G(12)3c'; > $efg = 'MC10.G(12)3c'; > > Now I want to check whether they are same or not by doing > if ($abc =~ /$efg/) { do something;}
Why not use $abc eq $efg if you only want to check for equality? > For this I need to insert a '\' before every special char. > Can some one tell me an easy way to do ? You can also use the qr operator to quote metacharacters in a string or scalar value: my $re = qr( $efg ); if( $abc =~ /$re/ ) {...} See the section "Regexp Quote-Like Operators" in the perlre manpage for details on qr(). HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]