Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: No need to escape right brace in regex

by biohisham (Priest)
on Oct 21, 2014 at 09:30 UTC ( #1104546=note: print w/replies, xml ) Need Help??


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 (Bishop) 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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2020-05-27 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (152 votes). Check out past polls.

    Notices?