Hi all! I have a problem in getting values/keys from a dereferenced hash.
I get that hash by reading a file where it was written to before and evaluating it to a variable via eval():

my @file = <filehandle>; my $line = join "", @file; my $results = eval ($line);

I can access values (using a reference to that hash) when I manually look for a key in the file and use it in my code:

$test = $$results{"key"};

The problem is that I don't know the keys of that hash when reading from file since it's built at runtime with changing keys/values.
I can't get the keys by using each(), keys() or values() since these don't like references it seems.
Is there a possibility to evaluate that hash from the file to a real hash, or is there any way to get the keys from that dereferenced hash?

TIA, Michael
PS. My apologies for posting that topic before as anonymous, I forgot to enable cookies... ;-)

davorg: fixed code tags


In reply to Getting keys/values from a referenced hash by professa

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.