Jeff 'japhy' Pinyan wrote:

Here you want to do:

      foreach my $key (keys %$result) {

since each element in @results is a hash-ref, and $result is an element from @results, you need to gets its keys. Since $result is a hash reference, you need to write %$result to get at the hash.


I've never liked the way
        %$somevar
which, while legal syntax, looks. Too easy to visually confuse, whereas
        %{$somevar}
is much clearer that we're dereferencing a hashref, and that if you want to extract a value, you instead hang the {}'s off of the dereference operator -> as in
        $somevar->{$key}

While it requires two extra keystrokes, it definitely improves maintainability, to my eye. (particularly when staring blearily at code in the wee hours of the morning wondering why it won't work. :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to