Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

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

As a "i just now made this up rule of thumb", use braces when parens won't do. Parens are just a fragile container for lists, they will flatten by default:

my @one_d = ( (1,2,3), (4,5,6), (7,8,9) );
is really just a single list. You have to use braces:
my @two_d = ( [1,2,3], [4,5,6], [7,8,9] );
I prefer to use a reference to an anonymous array for the outside container, maily because there is no mixing of parens and braces, square or curly:
my $two_d = [ [1,2,3], [4,5,6], [7,8,9] ];
When in doubt, always consult Data::Dumper. Always! If you had used Data::Dumper on your data structure, you would have seen that the problem was within it:
print Dumper \@AoH; __END__ (it's an AoHoH ... not an AoHoAoH) $VAR1 = [ { 'page' => { 'paragraph' => 'lesson1' }, 'chapter' => 'Basic', 'HASH(0x8638dec)' => undef }, { 'HASH(0x86fee04)' => undef, 'page' => { 'paragraph' => 'lesson3' }, 'chapter' => 'Advanced' } ];
Finally, print out a copy of References quick reference. And don't forget about Data::Dumper! :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re^3: Accessing an AoHoAoH by jeffa
in thread Accessing an AoHoAoH by bradcathey

Title:
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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found