On Mon, Mar 25, 2002 at 01:19:36PM -0600, Jared Burns wrote: > I've got a file containing the text: > blah > grah > > and I want to replace those two lines with the string: > broohaha > > I've tried using: > perl -pi -e 's/blah\ngrah/broohaha/' file > > I've also tried: > perl -pi -e 's/blah\ngrah/broohaha/s' file > perl -pi -e 's/blah\ngrah/broohaha/m' file > perl -pi -e 's/blah\ngrah/broohaha/ms' file > > all with no success. What am I doing wrong? How do I replace a string that > spans multiple lines? > I may be wrong, but since -p does a 'while (<>) {...}' around your -e code, the angle operator "<>" is readline()-ing newline-terminated lines from the file, so /\n.+/ will never match. How about perl -pi -e 'BEGIN{undef $/} s/blah\ngrah\n/broohaha/' file or such? Could be a real dog on a big file though. -- johntrammell at yahoo.com | 78BA 706C C5F9 9321 E7C4 933B D063 907B A88E 924B Twin Cities Linux Users Group (TCLUG) Mailing List http://www.mn-linux.org Minneapolis/St. Paul, Minnesota irc.openprojects.net #tclug