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! :)
-
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.