Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Usage of avriables with special charachters in regexp

by ISAI student (Scribe)
on Oct 24, 2011 at 11:27 UTC ( #933360=perlquestion: print w/ replies, xml ) Need Help??
ISAI student has asked for the wisdom of the Perl Monks concerning the following question:

Hello all. The code below issues an error. How can I get it to work (check if variable $str has the chrachter value)? code is:

#!/usr/bin/perl -w #1 line checker #use strict; $m='('; print $m,"\n"; $str="Hello\(\n"; $true=($str=~m/$m/); print $true , "\n";
And the PERL engine error is:
liord@analog4 188 > ~/linecheck.pl ( Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE / at /users/l +iord/linecheck.pl line 7. Exit 9

The following code works, but it is not parametric, and of no added value:

#!/usr/bin/perl -w #1 line checker #use strict; $m='('; print $m,"\n"; $str="Hello\(\n"; $true=($str=~m/\(/); print $true , "\n";

Comment on Usage of avriables with special charachters in regexp
Select or Download Code
Re: Usage of variables with special characters in regexp
by moritz (Cardinal) on Oct 24, 2011 at 11:40 UTC
      It works. Thanks!
Reaped: Re: Usage of avriables with special charachters in regexp
by NodeReaper (Curate) on Oct 24, 2011 at 13:08 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://933360]
Approved by keszler
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2014-12-26 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (168 votes), past polls