[Israel.pm] using perl -pi but with s///s
Levenglick Dov-RM07994
DovL at freescale.com
Mon Apr 11 01:55:35 PDT 2005
Perl -i -pe 'undef $/; s/this/that/g' file
Best Regards,
Dov Levenglick
The information contained in this email is classified as:
[ ] General Business Information
[ ] Freescale Internal Use Only
[ ] Freescale Confidential Propriety
[x] Personal Memorandum
-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On Behalf Of Gaal Yahas
Sent: Monday, April 11, 2005 9:27 AM
To: Perl in Israel
Subject: Re: [Israel.pm] using perl -pi but with s///s
On Mon, Apr 11, 2005 at 09:02:36AM +0300, Yossi.Itzkovich at ecitele.com wrote:
> I want to substitute in a file a multiline text:
> s/something/somewhat/gs
>
> How can I do it using perl -pi ? (perl -p reads line by line)
Use the -0 switch to specify a different input record separator. If your
data is text with paragraphs, and your pattern doesn't span paragraphs,
your best bet is to use the special -00 mode.
If not, you'll need to find something else that isn't in your pattern
and that hopefully still occurs regularly enough so that you don't have
to read huge chunks into memory at once.
If your file is small, all this doesn't matter much. Use slurp mode
(-0777).
--
Gaal Yahas <gaal at forum2.org>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl
More information about the Perl
mailing list