while() { my ($name, $data) = split "="; my @data = split ',', $data; for my $i ( 0.. $#data ) { next unless $data[$i] eq 'ResGen'; # found a ResGen so see what we had 3 commas ago (do bounds check to0) next if $i -3 < 0; my $back_a_bit = $data[$i -3]; print chop($back_a_bit) eq '"' ? "$name: Found quote\n" : "$name: No quote\n"; } } __DATA__ GENE1="Rattus norvegicus serum and glucocorticoid-regulated kinase (sgk) mRNA, complete cds,NM_019232,333,ResGen,ATP binding|protein serine/threonine kinase|protein amino acid phosphorylation,,,,29517 GENE2="ESTs, Weakly similar to putative serine/threonine protein kinase MAK-V [M.musculus]",NM_144755,331,ResGen,,,,,246273 GENE3="Thiosulfate sulphurtransferase (rhodanese)",X56228,329,ResGen,mitochondrion|sulfatetransport|thiosulfate sulfurtransferase,,,,25274 GENE4="Spleen tyrosine kinase,NM_012758,327,ResGen,ATP binding|protein tyrosine kinase|intracellular signaling cascade|protein amino acid phosphorylation,,,,25155 GENE5="Spleen kinase 24,NM_012758,,ResGen,ATP binding|protein tyrosine kinase|intracellular signaling cascade|protein amino acid phosphorylation,,,,25155 __END__ GENE1: No quote GENE2: Found quote GENE3: Found quote GENE4: No quote GENE5: No quote