Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Using map and grep to Sort one list using another list

by johngg (Canon)
on Feb 05, 2007 at 14:17 UTC ( [id://598304]=note: print w/replies, xml ) Need Help??


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

I don't see that happening. Perhaps I have missed something.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://598304]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found