[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Pushing Arrays into Hashes



I'm playing with the example on page 273 of _Programming Perl_ and
was wondering how to push additional arrays into the appropriate
place within the hash.

--
#!/usr/bin/perl -w

use strict;

my (%hash, $item);

%hash = (
	key => {
		inner_key => 'inner_value',
		array => [
			{ array_key => 'array_value1', },
		 	{ array_key => 'array_value2', },
		],
	},
);

for $item (@{ $hash{'key'}{array} } ) {
	print "$item->{array_key}\n";
}
--

What I'm after is a way of adding another '{ array_key =>
'array_value3', },' so that the print statement outputs:
--
array_value1
array_value2
array_value3
--

Any ideas?
-- 
My brain hurts!
SeanC
                      Mediatek Training Institute
            129 Moore Road, Berea, Durban, South Africa
    phone: +27 (0)31 305 4200              SeanC@mediatek.co.za
      fax: +27 (0)31 305 4236
                   <http://members.xoom.com/s_carte>

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org