Re: Help with extracting text file

2003-11-25 Thread John W. Krahn
Zary Necheva wrote: > > Hi everyone, Hello, > I have a file with data similar to this > .. > Ex|FEx|NQxx|OUxx|GExx|OVxxx|IQ|OR > Ex|FExx|NQxx|GExxx|OVxx|OUxx|IQxxx|ORxxx > Ex|FExxx|NQxx|OUxx|OVxxx|ORx

Re: Help with extracting text file

2003-11-25 Thread Rob Dixon
Rob Dixon wrote: > > use strict; > use warnings; > > open INFILE, 'myfile.txt' or die $!; > > while () { > chomp; > my @fields = split /\|/; > my @output = grep /^(E|FE|NQ|IQ)/, @fields; > print join('|', @output), "\n"; > } > > **OUTPUT > > Ex|FEx|NQxx|IQ > Ex|FExxx

Re: Help with extracting text file

2003-11-25 Thread Rob Dixon
Hi Tim. Sorry, but may I mess with your code? :) Tim Johnson wrote: > > Zary Necheva wrote: > > > > I have a file with data similar to this > > .. > > Ex|FEx|NQxx|OUxx|GExx|OVxxx|IQ|OR > > Ex|FExx|NQxx|GExxx|OVxx|OUxx|IQxxx|O

RE: Help with extracting text file

2003-11-25 Thread Tim Johnson
This is a pretty classic example of where split and join come in handy. Here I'm reading each line, splitting it into fields by the pipe character, then creating a new array with only those fields that begin with the letters I specify. Then I use join to make a string with those fields I chos