in reply to Substitute script for a newbie

UPDATE, I reaped this against social norm. I had mentioned that I like extended regexes (/x) so that I can comment them. E.g.

m/^A.TL5 ([EF]) # my match here 00/x

I like this because later the comment will help me to remember what I was doing, and in general regexes can be hard to read. I mistakenly extended this to to s///.

s/^A.TL5 ([EF]) # my match here 00 / NEW \s+ {$1} # replae here /x
Toolic pointed out that extended regexes in s/// only work on the matching part, not the replacing part. So this, I hope, is the legal one:
s/^A.TL5 ([EF]) # my match here 00 /NEW {$1}/x

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re^2: Substitute script for a newbie
by toolic (Bishop) on Jul 14, 2015 at 18:05 UTC
    The /x modifier only works for the PATTERN (left side) of the substitution operator; it does not work for the REPLACEMENT (right side). Run your code to confirm.
Re^2: Substitute script for a newbie
by Laurent_R (Canon) on Jul 14, 2015 at 18:49 UTC
    Sorry, Neil, but this is not the right way to modify a post on this site. You should leave the original content and add corrections clearly marked as updates, possibly strike out your original text or code, but please do not remove or change content without telling explicitly that you are doing that.

    Right now, toolic's post make no longer sense, because you changed you post without leaving unchanged its original content.

Re^2: Substitute script for a newbie
by Laurent_R (Canon) on Jul 14, 2015 at 20:16 UTC
    Thank you, Neil, for having quickly taken my advice into consideration and restored your post to something closely reflecting its original content. I'll upvote your post for that, despite the original mistake.