[Pdx-pm] Simplistic, yet complicated question....

aj aj at linuxaid.org
Mon Dec 9 12:47:40 CST 2002


Sorry about the confusion...

Again here is the data:

123454 text                67890 Get Rid of text
234555 more text to keep

The text I am wanting to remove is "67890 Get rid of text".  The only
pattern to this data is the multiple spaces between "12344 text" and
"67890 text".  The space pattern could be 2 or it could be 20.  I would
think if I could do a split on this the top line with a variable amount
of spaces and then I would just remove the second portion of the line. 
Does this make better sense?

Thanks Again, 
A.J. Weinzettel


On Mon, 2002-12-09 at 10:09, Jeff Zucker wrote:
> aj wrote:
> 
> > I am parsing a text file and I have the following layout of text
> > 
> > 
> > 123454 text                67890 Get Rid of text
> > 234555 more text to keep
> > 
> > My first idea is to substitue two spaces with nothing 
> > ( $line =~ s/  //g) and then try to do some sort of split on the
> > resulting.  I am sure there is a better way of doing this, but not
> > having too much luck finding an answer.  Any suggestions would be
> > greatly appreciated.
> 
> 
> You'll have to do a better job of describing what the constant factors 
> are and what you want to keep/eliminate.  Do you want to get rid of text 
> that is after the third set of whitespaces in a given line?  Or text 
> after the number 67890?  Or text after the second set of numerical data 
> in a line?  Or text that is after position X in each line?  Any of those 
> could describe the data you've shown.
> 
> If you can describe what you want to do in English (or some other human 
> language) it's usually fairly easy to do in Perl.
-- 
aj <aj at linuxaid.org>




More information about the Pdx-pm-list mailing list