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 don't think you can do multi-line regexps with a one-liner call of perl. The one-liner way of calling perl reads in your file line by line and acts on it, so its not able to match multi-line regexps. Look at the perlrun man page (and in particular the -e and -i options). So I think you'll have to turn this into a simple perl script to get it work or use sed. -- Jim Crumley |Twin Cities Linux Users Group Mailing List (TCLUG) crumley at fields.space.umn.edu |Minneapolis/St. Paul, Minnesota Ruthless Debian Zealot |http://www.mn-linux.org/ Never laugh at live dragons |Dmitry's free,Jon's next? http://faircopyright.org