in reply to Using map and grep to Sort one list using another list

Here's my go with grep. If you put your keys into a hash you can use exists to see if it's one we want.
#!C:/Perl/bin/perl.exe use strict; use warnings; my %keys = ( a => undef, e => undef, i => undef, o => undef, u => undef, ); my @records = qw{ 1|2|3|d|4 1|2|3|a|4 1|2|3|d|4 1|2|3|o|4 }; my @final = grep { my @flds = split '\|', $_; my $third = $flds[3]; exists $keys{$third} } @records; print "@final\n";
You could make that shorter but this way gives you a better idea of what's happening. output:
1|2|3|a|4 1|2|3|o|4