Richard Heintze wrote: >Is there a way I can explictly declare that each array >cell contains a hash? > >Here is the only way I know to do it: > >my @PCEs=[]; >while ($Data->FetchRow()) { > my %dh = $Data->DataHash(); > $PCEs[$cn]{$dh{"id"}} = $dh{"ridPCE"}; >} > >This "my" declaration only says that it is an array, >not an array of hashes. Can I improve upon this?
Why would you want to declare this? Since the anonymous hashes spring into existence automatically, no declaration is necessary. To access an element of your referenced hash, you have to add another scalar symbol like this: $$PCEs[$cn]{$dh{"id"}} ... Alternatively, you could improve the readability by using the arrow dereference, though: $PCEs[$cn]->{$dh{"id"}} = $dh{"ridPCE"}; The right side refers to the hash key "$dh{"id"} of the anonymous hash in $PCEs[$cn], and the value of $dh{"ridPCE"} is assigned as its value. - Jan -- There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence. - Jeremy S. Anderson -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>