> -----Original Message-----
> From: Mark Hanson [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 03, 2001 4:42 PM
> To: [EMAIL PROTECTED]
> Subject: add hash to hash of hash
>
>
> Hi,
>
> Still more hash questions:
>
> using the example in chapter 9 of Programming Perl:
>
> %HoH = (
> flintstones => {
> husband => "fred",
> pal => "barney",
> },
> );
>
> how can dynamically add another hash to %HoH? In Programming
> Perl, they have a hard coded example:
>
> $HoH{mash} = {
> captain => "pierce",
> ...
> };
>
> I've tried:
> $HoH{'mash'}{'captain'} = {'pierce'};
> and assorted variations...
Close. use:
$HoH{mash}{captain} = 'pierce';
{'pierce'} is an anonymous hash with 1 key (pierce) and a
missing value, which will default to undef. So your statement
is equivalent to:
$Hoh{mash} = { captain => { pierce => undef } };
-w or "use warnings" will issue a warning when you use
something like {'pierce'}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]