foreach my $line (@data) { chomp; if $line =~ /SMTP:/i {do stuff} }