Re: [Boston.pm] Is there a modifier on m or s that says the argument is not a regex

Conor Walsh <[email protected]> Sun, 13 Jan 2019 21:57:22 -0500
Newsgroups gmane.comp.lang.perl.perl-mongers.boston
Message-ID <CAFS=4=dMJ-w9AhwHGL98FqRJfMHZBf_toH0gcYOZFk3_oE5zJQ@mail.gmail.com>
Steve,

This sounds like a use-case for...  not using regular expressions. :)
https://perldoc.perl.org/functions/index.html
https://perldoc.perl.org/functions/substr.html

-C.

On Sun, Jan 13, 2019 at 9:29 PM Steve Tolkin via Boston-pm
<[email protected]> wrote:
>
> Is there a modifier for m  that says the argument is not a regular
> expression?  Similarly for the or the first argument to s?
> I looked and did not find it.
> This seems like it would be useful.
>
> I want to extract certain lines from a log file.  My perl program is
> basically  lots of lines like:
>
> print if m/some string/;
>
> If the string contains a left or right parenthesis I must escape it or else
> get an error message that says the argument is "not a regular expression".
>
> So I have to escape each parenthesis with a backslash, which is tedious and
> error prone.
> I presume I would also need to escape at least the open square bracket, but
> have not had those in the file.
>
> Also, the string often contains lots of dots, e.g., is
> com.example.foo/bar/program.c at line(123)  and this requested modifier
> would have a small performance benefit.
>
> --
> Steve Tolkin
>
> _______________________________________________
> Boston-pm mailing list
> [email protected]
> https://mail.pm.org/mailman/listinfo/boston-pm