in reply to Dereferencing a portion of a hash

What you have passed is a reference to a reference. If you do this instead:
report_block($report_data{$domain}{$provider}); sub report_block { my ($rpt_ref) = shift; print Dumper($rpt_ref); #access elements here! print $rpt_ref->{total}; }
Then you will have a simple hash reference and the arrow notation will work.

Replies are listed 'Best First'.
Re^2: Dereferencing a portion of a hash
by THRAK (Monk) on Feb 18, 2005 at 16:37 UTC
    Maybe this is a stupid question, but how is that passing a reference as a reference? Isn't what you've done (which does work) pass a copy of that portion of the hash? Or is it such that when you pass a portion of a hash it automagically passes it as a reference?
      $report_data{$domain}{$provider} is a hash reference already. This is shown by your data dumper (which shows that it contains hash key/values).

      You are then taking the reference to that hash reference by passing it as \$report_data{$domain}{$provider} which makes it a reference to a reference.

      Hence, you need to either not pass it that way or dereference it twice.

      $,=" : ";$\="\n"; print $_, $$rpt_ref->{$_} for keys %{$$rpt_ref};
      --------------
      It's sad that a family can be torn apart by such a such a simple thing as a pack of wild dogs
        Thanks, I see that now. Although I don't understand how it is a reference at that point. Prior to that point it is declared and I've simply been populating it via:
        my %report_data; ... $report_data{$domain}{$provider}{ok}++;