Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (10)
    As of 2014-09-17 16:33 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (91 votes), past polls