in reply to Better way to get the results of grep()?
my @looking_for = qw(Subject From); my $re = join '|', map quotemeta, @looking_for; $re = qr{^($re):}; my %header; for (@header) { if ($_ =~ $re) { push @{$header{$1}}, $_; } } my $curFrom = $header{From}[0]
The nice thing about this solution is that it scales well if you're looking for many different headers.
Update: fixed thinko in code, AnomalousMonk++
|
|---|