"It depends" (as the professors in my Economics classes liked to say).

If $obj->{$j}->{rxABC} holds a scalar value, you should be able to print it like this:

print "Found: $obj->{$j}->{rxABC}\n";

That reminds me. Anytime you have a -> between two brackets you can omit it. So that becomes:

print "Found: $obj->{$j}{rxABC}\n";

On the other hand, if $obj->.....{rxABC} holds a reference to another layer (an array ref or hash-ref, for example), you will need to deal with that layer too. Fortunately Perl can print an array in a sensible way. So let's say that {rxABC} holds an array ref like this:

$obj->{$j}{rxABC} = ['a', 'b', 'c'];

Then you would need to dereference that array ref to make sense of it too. Here's one way:

print "Found: ", join( ' ', @{ $obj->{$j}{rxABC} } ), "\n";

Or another way:

print "Found: @{$obj->{$j}{rxABC}}\n";

Dave


In reply to Re^4: I have a perl snippet. And I need help understanding it. Can you help answer these questions. by davido
in thread I have a perl snippet. And I need help understanding it. Can you help answer these questions. by Fighter2

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.