http://www.perlmonks.org?node_id=937821


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

Replies are listed 'Best First'.
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 :)