in reply to Re^2: Using map and grep to Sort one list using another list
in thread Using map and grep to Sort one list using another list
use strict; use warnings; use Data::Dumper; my @keys = qw{a e i o u}; my @records = qw{ 1|2|3|d|4 1|2|3|a|4 1|2|3|d|4 1|2|3|o|4}; my @result = map { my $key = $_; grep { m{^(?:\d\|){3}$key\|\d$} } @records } @keys; my $dd = Data::Dumper->new([\@result], [qw{*result}]); print $dd->Dumpxs();
produces
@result = ( '1|2|3|a|4', '1|2|3|o|4' );
Cheers,
JohnGG
|
|---|