if ($csv_line =~ /SEQ/) { # If the line contains 'SEQ' anywhere in it this will be true print "header\n"; } elsif ($csv_line =~ /^(\w)\t(\w)\t/) { # This will match a word character at the beginning of a line followed by a tab, another word character, and another tab print "Amino Acid:$1\nPrediction:$2\n"; }