note
grantm
<p>I think you'll find the enlightenment you're after in [http://perldoc.perl.org/perlreftut.html|perlreftut - Mark's very short tutorial about references].</p>
<p>When you called <code>$rows = $dbh->selectall_arrayref</code>, DBI returned a single scalar value which you assigned to <code>$rows</code>. That value was a reference to an array. Each element in that array was a reference to a hash of column names and values.</p>
<p>The array-dereferencing syntax you quoted:</p>
<code>$ { $array_ref } [2]</code>
<p>is exactly equivalent to this syntax:</p>
<code>$array_ref->[2]</code>
<p>And in your case would return a hashref.</p>
<code>
my $hash_ref = $array_ref->[2];
my $value = $hashref->{$key};
</code>
<p>You can also chain together the dereferencing like this:</p>
<code>
my $value = $array_ref->[2]->{$key};
</code>
<p>And you can even omit the arrow when the initial data structure contains references:</p>
<code>
my $value = $array_ref->[2]{$key};
</code>
1040177
1040177