#Capture header foreach $line (@array) { if ($line =~ /^>.+$/ ) { $header = $&; } }