http://qs321.pair.com?node_id=1104546


in reply to No need to escape right brace in regex

With Perl 5.18.2 on a Ubuntu 14.04 box I don't seem to get any error if I replace the double quotes for single quotes around the code, but when I try to reproduce the behavior in the cases you report (a.k.a escaping the brace or leaving it unescaped ) I get the following error

perl -le "$_=~/sub mymy\{}/;" syntax error at -e line 1, near ";=~" Execution of -e aborted due to compilation errors.

The error is consistently reported in all the cases you mentioned in your follow-up reply too


A 4 year old monk

Replies are listed 'Best First'.
Re^2: No need to escape right brace in regex
by syphilis (Archbishop) on Oct 21, 2014 at 10:21 UTC
    Yes, I'm on Windows. I think you really need to stick with single quotes on Ubuntu, otherwise things get a bit weird with the setting and interpolation of $_.
    The Windows shell doesn't interpolate on the "$" sign - as "$" isn't meaningful on Windows like it is on Linux.

    On my Ubuntu-14.04 with perl-5.18.0, the first time I run the command quoted above, it's fine.
    But after that I get errors too.
    sisyphus@sisyphus5-desktop:~$ echo $_ PATH $ perl -le "$_=~/sub mymy\{}/;" # No error here $ echo $_ PATH=~/sub mymy\{}/; $ perl -le "$_=~/sub mymy\{}/;" Backslash found where operator expected at -e line 1, near "mymy\" syntax error at -e line 1, near "mymy\" Execution of -e aborted due to compilation errors.
    The actual error messages can vary a bit, depending upon what gets run when - but I've seen the same error as you reported.

    Cheers,
    Rob
      That's right. The Windows shell does not apply on the "$" sign and is not significant on Windows as it is usually with Linux.