Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Seems to be a popular question for newcomers to ask how to access some component of a complicated structures.

The answer is to user the built-in debugger.

tlegrady@rw-q318:~$ perl -d Loading DB routines from version 1.3 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::( my $data = [ DB<1> n main::( my $test = $data->{ name }; DB<1> x $data 0 ARRAY(0x70b910) 0 HASH(0x70b970) 'name' => 'Mary' DB<2> x $data->[0] 0 HASH(0x70b970) 'name' => 'Mary' DB<3> x $data->[0]{name} 0 'Mary'

When the debugger starts, it shows that it's about to execute line 5. I do a "next" ( 'n') to complete that, and then it's going to execute line 16. I query the debugger to show the value of $data, and then of its components. Since you're looking right at it, it's easy to tell you want array element '0', hash tag 'name'.

As Occam said: Entia non sunt multiplicanda praeter necessitatem.

In reply to Re: Access to hash ref element by TomDLux
in thread Access to hash ref element by Anonymous Monk

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-05-29 23:46 GMT
Find Nodes?
    Voting Booth?

    No recent polls found