That's not how to dereference a hash ref. You're trying to deref it as a scalar, which it isn't, and that's why it's throwing the error.

I was wrong... $$href{try} does actually work. My bad :) I can't figure out why you're receiving that error with the code you've supplied though. Can you post more context?

Dereference individual items with the -> deref operator:

# hashref $h_ref->{try}; # arrayref $aref->[0]; # scalar $$scalar_ref;

...and to dereference entire structures:

# hash my %hash = %$hash_ref; # array my @array = @$aref;

If you need to dereference an entire list-type reference out of a nested structure, you need to use the circumfix operator:

# hash my %hash = %{ $hash_ref->{inner_href} }; # array my @array = @{ $aref->[0] };

A bit more complicated... extract one list-type variable out of a different list-type variable:

# array from href my @array = @{ $href->{inner_array} }; # hash from array ref my %hash = %{ $array->[0] };

In reply to Re: PTKDB - exception catched Not a SCALAR reference by stevieb
in thread PTKDB - exception catched Not a SCALAR reference by pjkang7

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.