in reply to How to access info from the array
General answer : References quick reference.
More specific answer: $data{$formname} is an entry in a hash. The wrapping of the @{ ... } around it indicates that this hash entry is a reference to an array. What's being pushed onto the array is an anonymous hash (reference to a hash with no name).
Putting that together listily:
-
$data{$formname} => reference to an array
- dereference with @{ REFERENCE }
- $data{$formname}->[0] => the first element of that array. Perl lets you tighten that up to
$data{$formname}[0]. The element of that array is a reference to a hash, so
- dereference with %{ REFERENCE }
- $data{$formname}->[0]->{type} (also $data{$formname}[0]{type} ) => The value of the 'type' field in the anonymous hash. This is a normal scalar, and so needs no dereferencing.
So, to iterate over the keys of that (anonymous) hash, you might do
foreach my $key ( keys %{ $data{$formname}[0] } ) { print $key, " ", $data{$formname}[0]{$key}, "\n"; }
HTH
If not P, what? Q maybe?
"Sidney Morgenbesser"
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: How to access info from the array
by gnangia (Scribe) on Nov 12, 2002 at 21:33 UTC | |
by clairudjinn (Beadle) on Nov 13, 2002 at 02:20 UTC |
In Section
Seekers of Perl Wisdom