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"
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|