0

Why is this failing?

WGroleau@MBP Chords % perl -p -i -e '(Trinidad|Donoso|Clifton|Frincke|Little|Church|Antonio) XYZ :\1\t:g;' *txt 
Bareword found where operator expected at -e line 1, near ") XYZ"
    (Missing operator before XYZ?)

I have used this syntax many times in the past without this error (as far as I can remember).

1 Answer 1

1

Can you test:

perl -i -pe 's:(Trinidad|Donoso|Clifton|Frincke|Little|Church|Antonio) XYZ :$1\t:g' *txt

You missed the first part of substitution:

s:

And in perl, the captured group is $1, not \1 (maybe can work in both cases).

2
  • (face palm!) — but the backslash has always worked and still does
    – WGroleau
    Commented May 4, 2023 at 18:36
  • This is not Perl's syntax, but can work. Commented May 4, 2023 at 18:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .