Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
O wise and learned monks of the perl (and particularly Christian persuasion), I seek wisdom on how to join all the elements of my array that I've referenced in a hash. I've parsed out sections of a text bible into a structure that I reference by book, chapter, and verse. I have tried to save my results to a hash that looks like:
... my @saved_verses = @verses; $bible{$book}{$chapter}{'verses'} = \@saved_verses; @verses = (); # use again for next chapter
which I try to subsequently access to get either individual verses out, or to print all the verses in a particular chapter. 2 questions: 1. Is this the right way to copy off the @verses array so that I can reuse it when parsing the next chapter? or will I have the same problem with @saved_verses being replaced with the new verses? 2. When trying to access all the verses of a particular chapter, how do I join all the verses? (i.e. I want all the verses in Genesis Chapter 1) I seem to be able to access individual verses but can't seem to join on the array:
my $n = 0; $bible{$bookname}{$chapter}{'verses'}[$n]; # but neither of the following seem to work join("\n\n",$bible{$bookname}{$chapter}{'verses'}[0..$#{$bible{"$b +ookname"}{"$chapter"}{'verses'}}]); join("\n\n",$bible{$bookname}{$chapter}{'verses'}); # I get instead ARRAY(0x[0-9]*) or Argument "" isn't numeric in ar +ray element at ...
Hoping for a revelation on the proper procedures.

In reply to 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
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (8)
    As of 2018-03-17 19:14 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (225 votes). Check out past polls.