If your task is to select those groups of lines in file 2 where the identifier in the first row of the group is in file 1, you should read file 1 into a hash for easier lookup and then loop over file 2. For example like this:
use strict; use warnings; # read file 1 into hash, don't forget to chomp; # left as exercise # result should look like this: my %file1 = ( '>SR1.2' => 1, '>SR1.3' => 1, ); # loop over file two while(<DATA>){ next unless /^(>.*?)\s/ and exists $file1{$1}; print $_.<DATA>.<DATA>.<DATA>; } __DATA__ >SR1.1 HWI-ST ATGCTGCT TCGTCGAT CTGATCAGCTAC >SR1.2 HWI-ST0 TTTTGCTGCT TCGTTGGG CTTTATCAGCTAC >SR1.3 HWI-ST0787 GGGGGCTGCT AATCGTCGAT AACTGATCAGCTAC >SR1.4 HWI-ST0787 GGGGGCTGCT AATCGTCGAT AACTGATCAGCTAC
|
|---|