On Apr 20, 2004, at 9:27 AM, Sanyal, Dibya F ((Corporate, consultant)) wrote:


Hi,


I have 2 arrays. One holds all uniq key values of an associative list (all ssn), other holds the associated values (their names). I need to create a hash by putting these arrays together. Each entry in that hash would be (ssn => name).

I can iterate over one array and create the hash. Is there any inbuilt function (or a real cool piece of code) that does the same?

Well, I don't no about "real cool", but:


my @ssns = ('111-11-1111', '222-22-2222', '333-33-3333');
my @names = qw(One Two Three);

my %ids = map { $ssns[$_], $names[$_] } 0..$#ssns;

Hope that helps.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to