On Mar 11, 2009, at 11:51 PM, Chas. Owens wrote:

Dereference the hashref as an arrayref then ask for the keys:

#!/usr/bin/perl

use strict;
use warnings;

my %hash = ( adams => {} );

my @keys   = qw/a ar af aw/;
my @values = (1, 19, 13, 11);

@{$hash{adams...@keys} = @values;

use Data::Dumper;

print Dumper \%hash;


Thank you for both a solution and several other useful tips as well!

It's still not intuitive to me why we FIRST "convert" the hash to an array, and THEN ask for keys - keys being hash-ish, rather than array- ish sorts of things. (I've said that badly.) What exactly are the elements of the array @{$hash{adams...@keys} ?

Thanks,
Chap.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to