Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Possible Match Problem

by AnomalousMonk (Chancellor)
on Jan 19, 2012 at 06:05 UTC ( #948688=note: print w/replies, xml ) Need Help??

in reply to Re: Possible Match Problem
in thread Possible Match Problem

... a couple of ways to ... use all these characters verbatim ... qr is another.

In no way will  qr use any metacharacters verbatim unless specifically 'told' to do so, e.g., by a  \Q ... \E escape sequence.

>perl -wMstrict -le "my $s = 'hi('; my $rx = qr{$s}; " Unmatched ( in regex; marked by <-- HERE in m/hi( <-- HERE / at ...

Update: See  qr in the Regexp Quote Like Operators section of perlop, also see section on 'escape sequences' (for \Q) in Quote and Quote like Operators, also in perlop.

Replies are listed 'Best First'.
Re^3: Possible Match Problem
by Marshall (Abbot) on Jan 19, 2012 at 08:30 UTC
    correct. qr is better used for other things. my example was with \Q...\E, so I'll leave it at that.
      if ($str2 =~ /\Q$str1\E/) #\Q...\E means like qr #don't interpret characters #like '(' within $str1 #use them verbatim

      To avoid misunderstanding, you might also consider removing "like qr" from the foregoing comment, or possibly changing to something like "means, as when used in qr, to avoid interpreting characters like ...".

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948688]
[erix]: easily amused...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-12-18 06:29 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (468 votes). Check out past polls.