Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to juggle between two arrays that are not same size

by mwah (Hermit)
on Dec 19, 2007 at 18:23 UTC ( [id://657943]=note: print w/replies, xml ) Need Help??


in reply to How to juggle between two arrays that are not same size

the solution presented by kyle is somehow idiomatic, this would be a good choice. You can use an alternative form w/regular expressions in order to solve a more complicated pattern problem.

The regex-form of kyle's solution would be like:

... my @Names = qw'A B C'; my @FullRecord = qw'A_1 D_4 C_3 F_6 B_2'; # prepare temporary dictionary my %h; @h{@Names} = (); my @DesiredRecord = grep exists $h{ [/^([^_]+)/]->[0] }, @FullRecord; print "@DesiredRecord\n"; ...

Regards

mwa

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-19 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found