On Dec 11, George Georgalis said:

>On Thu, Dec 11, 2003 at 09:05:20AM -0500, Jeff 'japhy' Pinyan wrote:
>>On Dec 10, George Georgalis said:
>>
>>>giving my perl a retry, I found some hints on a website to recursively
>>>replace text
>>>
>>>perl -p -i -e 's/old\(.\)atext/new\1btext/g;' $( find ./ -name '*.html' -o -name 
>>>'*.txt' )
>>
>>This isn't recursively replacing text; it's recursively going through a
>>directory tree.
>>
>>>but from what I can tell, perl doesn't support the \1 for \(*\) symbols
>>>like sed does.  What is the work around?
>>
>>Because Perl is not sed.  Perl uses (...), not \(...\) for its memory
>>capturing.  In Perl's regexes, all non-alphanumeric metacharacters don't
>>use backslashes.  That means [...] for character classes, not \[...\], and
>>+ for " 1 or more", not \+, and so on.
>
>that's what I needed to hear... however replacing text (with memory
>capturing) is still a problem:
>
>perl -p -i -e 's/451(.)8229/331\12027/g;' $( find ./ -type f -name '*.html' -o -name 
>'*.txt' )

Right; first of all, \1 should only be used IN the regex ITSELF.  Outside
of the regex, you should use $1.  However, "331$12027" still isn't
appropriate; you'll need "331${1}2027".  The reason "331\12027" gave you
"331P27" is because octal character 120 is "P".

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to