Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: how to avoid using index of array

by clueless newbie (Hermit)
on Nov 13, 2011 at 13:55 UTC ( #937821=note: print w/ replies, xml ) Need Help??


in reply to how to avoid using index of array

Use a hash?

use strict; use warnings; my @guys=qw(Tom Dick Harry); my @gals=qw(Jane Mary Pamela); # The real work ... my %marriages; @marriages{@guys}=@gals; for my $guy (keys %marriages) { print "$guy - $marriages{$guy}\n"; }
prints
Dick - Mary Harry - Pamela Tom - Jane


Comment on Re: how to avoid using index of array
Select or Download Code
Re^2: how to avoid using index of array
by TomDLux (Vicar) on Nov 14, 2011 at 02:48 UTC

    Didn't you ever do first grade? Dick is with Jane and their baby is Spot.

    As Occam said: Entia non sunt multiplicanda praeter necessitatem.

      Now we know what D in TomDLux stands for :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2015-07-05 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls