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

Jeff Zucker jeff at vpservices.com
Mon Dec 9 12:09:54 CST 2002

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.


More information about the Pdx-pm-list mailing list