in reply to Parsing a tab delimited file
If I got that right, then I think something like the following will do:
You may want to look at "qr" on the perlop manpage (under "Regexp Quote-like Operators), if you have a lot of molecule patterns to look for and/or a lot of locus data to go through. The "print if" condition says that there must be 6 fields on the line, and the set of molecule strings in $bigRegex needs to match either at the beginning of each line, or after the first tab character.open( MOL, "molecules" ); @molecules = <MOL>; close MOL; map { chomp; $_ = quotemeta; } @molecules; $bigRegex = join '|', @molecules; open( LOCUS, "locus" ); @locus = <LOCUS>; close LOCUS; foreach (@locus) { print if ( scalar( split /\t/ ) == 6 && /^([^\t]+\t)?($bigRegex)/ ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a tab delimited file
by particle (Vicar) on May 10, 2002 at 16:35 UTC | |
by graff (Chancellor) on May 13, 2002 at 20:59 UTC | |
by particle (Vicar) on May 13, 2002 at 22:37 UTC |