[Israel.pm] using perl -pi but with s///s

Gaal Yahas gaal at forum2.org
Sun Apr 10 23:27:06 PDT 2005


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/



More information about the Perl mailing list