|FROM ||Ruben Safir
|SUBJECT ||Re: [NYLXS - HANGOUT] A simple perl script
|From owner-hangout-outgoing-at-mrbrklyn.com Thu Dec 15 06:25:50 2011
Received: by www2.mrbrklyn.com (Postfix)
id 3202D100B72; Thu, 15 Dec 2011 06:25:50 -0500 (EST)
Received: by www2.mrbrklyn.com (Postfix, from userid 28)
id 20C1D100B80; Thu, 15 Dec 2011 06:25:50 -0500 (EST)
Received: from mailbackend.panix.com (mailbackend.panix.com [188.8.131.52])
by www2.mrbrklyn.com (Postfix) with ESMTP id CDCF7100B72
for ; Thu, 15 Dec 2011 06:25:49 -0500 (EST)
Received: from panix2.panix.com (panix2.panix.com [184.108.40.206])
by mailbackend.panix.com (Postfix) with ESMTP id 7A66A28E55
for ; Thu, 15 Dec 2011 06:27:33 -0500 (EST)
Received: by panix2.panix.com (Postfix, from userid 20529)
id 69A3D33C94; Thu, 15 Dec 2011 06:27:33 -0500 (EST)
Date: Thu, 15 Dec 2011 06:27:33 -0500
From: Ruben Safir
Subject: Re: [NYLXS - HANGOUT] A simple perl script
Content-Type: text/plain; charset=us-ascii
User-Agent: Mutt/1.5.20 (2009-06-14)
On Wed, Dec 14, 2011 at 09:54:19PM -0800, Elfen Magix wrote:
> I was thinking of Grep as well.
you can perldoc the perl grep function or just use a regex test
next CLOSE_CHAPTER if m"Chapter \d\d"
or something like that. I'm rusty.
> The problem is simple (maybe not):
> -Its a story text file in acsii.
> -It has many chapters
> -The chapter index numbers 1 - 13 are fine, skips 14, and continues with 15 to 75.
> -The format of the chapter line (all 75 are in 1 file) is:
> "Chapter XX: Chapter Name" Where XX is any number from 0 - 9, counting all 75 chapters.
> I was thinking of grep to find the chapter lines (which I can do and does work) but changing the numbers is what I cant figure out.
> grep 'Chapter' /file name? - gets the chapter lines and posts them. But changing them?
> BTW- I can remove chapters 1 - 13 temporarily while this change happens.
> From: Kevin Mark
> Subject: Re: [NYLXS - HANGOUT] A simple perl script
> On Wed, Dec 14, 2011 at 04:27:39PM -0800, Elfen Magix wrote:
> > I need a simple thing that goes through a file to find "Chapter [and a number]
> > ". Then it must increment that number by 1 and resave the file without altering
> > nothing else.
> > I know I've seen this, and even wrote one years ago myself, but I cant for the
> > life of me remember how!
> > Thanks.
> That is sort-of a loose definition for a program specification.
> if its one line in one file, you can just open it in vi and search for it and fix it.
> if you need it done in 10's or 100's of places, if might be a few lines of sed, awk or grep.
> grep "Chapter" filename