#!/usr/bin/perl use warnings; # YOU FORGOT THESE! use strict; open HEADF, '; close HEADF; # create a regexp to search for all headers at once # like this: (BLABLABLA|ASKDJFASD) will match either # of the two. my $regexp = '(' . join('|', @headers) . ')'; print 'Enter filename: '; my $fasta_fn = ; chomp $fasta_fn; # remove newline, paranoia open FASTAF, '<', $fasta_fn or die "can't open $fasta_fn: $!"; while() { # $_ = the line of text from the file now... # m!! is like using // to match text, m just tells # perl to use a different surrounding character: ! # m!$regexp!o by itself matches against $_ automagically! # (the o says only read the value in $regexp once, # it won't change anyway) # print by itself prints $_ automagically! print if(m!$regexp!o .. m!//! and not m!//!); } close FASTAF;