Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Concordance Printing of Two Arrays

by NateTut (Deacon)
on Oct 17, 2005 at 18:55 UTC ( [id://500790]=note: print w/replies, xml ) Need Help??


in reply to Concordance Printing of Two Arrays

Depending on what else you want to do with these values you might want to put them in a hash:
use strict; use warnings; my @num = qw (1 2 3 4 5); my @alp = qw (A B C D E); my %numalp; # # Build the hash... # for my $index (0 .. $#num) { $numalp{$num[$index]} = $alp[$index]; } # # Print it # foreach (sort(keys(%numalp))) { print("numalp\[$_\]\[$numalp{$_}\]\n"); }
This way they remain associated if you need them again...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found