in reply to •Re: Re: Regular expressions Containing Octal values?
in thread Regular expressions Containing Octal values?


I don't get it. Isn't the previous successful match at the LHS of the s///? Isn't that interpolated into this regex? Like this:
#!/usr/bin/perl -wl use strict; $_ = "3 L-homoserine"; /(\w-\w)/; print $1; s/(\d*\s*)L-homoserine/${1}2-Amino-4-hydroxybutyric acid/; print; $_ = "L-homoserine"; s/(\d*\s*)L-homoserine/${1}2-Amino-4-hydroxybutyric acid/; print; __END__ Prints: L-h 3 2-Amino-4-hydroxybutyric acid 2-Amino-4-hydroxybutyric acid

--
John.

Replies are listed 'Best First'.
•Re: Re: •Re: Re: Regular expressions Containing Octal values?
by merlyn (Sage) on May 17, 2002 at 16:06 UTC
    Ahh, I totally missed that we were talking about the RHS (a qq string) instead of the LHS (a qr string). In that case, $1 (and in this case, ${1}) are the only things that should be used. The \1 construct works only as an error-correction DWIM that as shown can be sometimes ambiguous.

    -- Randal L. Schwartz, Perl hacker