Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: relating arrays

by dvergin (Monsignor)
on Dec 05, 2002 at 20:27 UTC ( [id://217889]=note: print w/replies, xml ) Need Help??


in reply to relating arrays

Assuming (as we must -- else your problem has no clean solution) that the elements in @data are unique.

Given:

my @data = ('70.1', '75.3','76.5', '87.4'); my @numbers = ('0.001','0.34','0.456','0.521');
...then just do:
my %look_up; @look_up{@data} = @numbers;
...and then you can retrieve the values as needed. E.g.: print $look_up{76.5}, "\n";   # prints: 0.456

------------------------------------------------------------
"Perl is a mess and that's good because the
problem space is also a mess.
" - Larry Wall

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 00:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found