in reply to Re: unless condition not working
in thread unless condition not working

Thanks for the reply. I used your recommendation to use qr but unfortunately it still has issues concerning to quotemeta related lines. My txt file is a combination of normal as well as quotemeta related lines. So at a time I am able to get output either for normal lines or quotemeta lines. Please correct me if I doing something wrong.

unless($line =~ qr/$pattern/){ ... #works only for normal lines unless($line =~ qr/\Q$pattern\E/){... #both normal as well as quotemet +a related lines are failing and everything is getting list in output.

Could you please let me know what is wrong step I am doing?

Replies are listed 'Best First'.
Re^3: unless condition not working
by Anonymous Monk on Dec 05, 2011 at 08:11 UTC

    Could you please let me know what is wrong step I am doing?

    You're using the qr operator as if it were the m operator (match), but they're not the same. See Regexp Quote-Like Operators in perlop

    And you only quotemeta arbitrary text you wish to match verbatim, not regex patterns.

    You can build an efficient regex pattern out of a list of arbitrary text with Regex::PreSuf.