[NTLUG:Discuss] perl question

MadHat madhat at unspecific.com
Wed Jun 4 11:00:56 CDT 2003


On Wed, 2003-06-04 at 10:43, Bobby Wrenn wrote:
> On Wed, 2003-06-04 at 09:52, Michael Patrick wrote:
> > On Wed, Jun 04, 2003 at 09:49:02AM -0500, Bobby Wrenn wrote:
> > > I have a text file in the following format:
> > > 
> > > name1
> > > [name2]
> > > address1
> > > [address2]
> > > city, state [zip]
> > >
> > 
> > How is the next record done?  Is there a space between them so you could read each line then we you hit a blank line you'll know city, state [zip] was the preceding line?
> > 
> > Michael 
> > 
> Each line is terminated with a <cr>. There are no blank lines between
> records,

Unless you can guarantee that the name field will never have a comma (,)
and you can guarantee that the city/state field will, you are in a
pickle.

Like is someone is 'Richard Cranium, Jr', then you couldn't use the
existence of the comma to determine the end of each record.  Or even
matching on a word followed by a comma then 2 characters.

-- 
MadHat at Unspecific.com
`But I don't want to go among mad people,' Alice remarked.
`Oh, you can't help that,' said the Cat: `we're all mad here...'
   -- Lewis Carroll - _Alice's_Adventures_in_Wonderland_




More information about the Discuss mailing list