Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
for ( keys %{ $bible{'Genesis'}{'chapter 1'} }) { print $_, ": ", @{ $bible{'Genesis'}{'chapter 1'}{$_} }, $/; }

That this loop prints your example data in the correct order is an artifact of the small number of verses in the data. Try adding the verses
    3 Three.
    4 Four.
    10 Ten.
to Genesis Chapter 1 and you will see the verses printed in apparently random order (really, the hashing order). Numerically sort the 'verse' keys before printing to get the correct order. (Tested.)

for (sort { $a <=> $b } keys %{ $bible{'Genesis'}{'chapter 1'} }) { print $_, ": ", @{ $bible{'Genesis'}{'chapter 1'}{$_} }, $/; }

Also, I would question your departure from the array-based nature of verse storage in the first place. johnko's OP example implies that each string/line is a verse and is stored in an array in verse order, and this is the way toolic's reply treats it. In your example, you store one and only one verse per anonymous array with the verse number as the hash key to the array, which seems a bit wasteful and, more importantly, potentially rather confusing. Are there, in fact, 'verses' that consist in more than one line of data?

I would also question how your book/chapter/verse parsing would handle books like "1 Corinthians", "2 Thessalonians", etc., but, as you say, this is all critically dependent on the exact format of the data johnko is parsing, which is not revealed to us.

In reply to Re^2: join all elements in array reference by hash by AnomalousMonk
in thread join all elements in array reference by hash by johnko

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [jedikaiti]: Hi Monks

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (8)
    As of 2018-04-19 17:53 GMT
    Find Nodes?
      Voting Booth?