🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.perl.misc
Article #56

Re: Find and Replace Perl function?

#56
From: Zenin
Date: Sun, 28 Jan 1996 00:00
28 lines
1616 bytes
Jeff Dilcher <dilcher@shellx.best.com> wrote:
: I would like to change a block of text
	>snip<
: I am a little stumped about how to write a little perl 
: routine to do this.  Does Perl have a built in function
: that can identify and replace a whole block of lines of text?
	Could be, 'don't know enough of perl yet to tell you. :)

	But if you are *sure* that each line of this block is not
	found anywere else in the file, you could use a big stick
	approch like this:

#!/usr/bin/perl
while(<>) {
  chop;
  s/^complete line one of the original block$/line ONE\nTWO\n\THREE+ of new block/;
  s/^original line two$//;
  s/^original line three$//;
  s/^etc$//;
  print;
}
______
     /	Spelling mistakes?  Their couldn't be. -My modem is error correcting.
    /	
   /    Zenin@Best.com			---->>ROCKY HORROR ARCHIVE<<----
  /	 ___ 	__  o   __		   http://www.best.com/~zenin
 /	/___\ |/  \ | |/  \	       ftp://ftp.best.com:/pub/zenin/RHPS/
/_______\___  |	  | | |   |_______________________________________________
Technical Details
Message-ID: <4egrab$6q4@shellx.best.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4egegu$ktj@shellx.best.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11488e,3978647afc3f661a
X-Google-Attributes: gid11488e,public
X-Google-Thread: fa0ae,3978647afc3f661a
X-Google-Attributes: gidfa0ae,public
From: Zenin <zenin@best.com>
Subject: Re: Find and Replace Perl function?
Date: 1996/01/28
Message-ID: <4egrab$6q4@shellx.best.com>
X-Deja-AN: 136866700
references: <4egegu$ktj@shellx.best.com>
organization: Rocky Horror, Barely Legal (Berkeley, CA)
cc: dilcher@shellx.best.com
followup-to: comp.lang.perl.misc,best.www
newsgroups: comp.lang.perl.misc,best.www