in reply to Help with perl error message
# List all search criteria
my @search = ( 'CCFN\d+NT','CCFN',
'EBGFN','EBG',
'PRFN','PR',
'BLSTDGG','BLSTDG','BL');
# Build an index of the fields they correspond to
my %index = map{ $earch$_ => $_ } (0..$#search);
# Make a hash to store the results
my %results = map { $_ => [] }@search;
# Make a generic regex, for one pass.
my $regex = join( '|' map{"($_)"}@search);
# Blah blah split and stuff.
# Use the bracketed results of the regex to store data.
m/$regex and push @{$results{$1}}, $line[$index{$1};
print Dumper \@results{@search};
--
Brother Frankus.
¤
|
|---|