<?xml version="1.0" encoding="windows-1252"?>
<node id="1010848" title="join all elements in array reference by hash" created="2012-12-29 15:07:56" updated="2012-12-29 15:07:56">
<type id="115">
perlquestion</type>
<author id="1010836">
johnko</author>
<data>
<field name="doctext">
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:
&lt;code&gt;
    ...
    my @saved_verses = @verses;
    $bible{$book}{$chapter}{'verses'} = \@saved_verses;
    @verses = (); # use again for next chapter
&lt;/code&gt;
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:
&lt;code&gt;
    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{"$bookname"}{"$chapter"}{'verses'}}]);
    join("\n\n",$bible{$bookname}{$chapter}{'verses'});
    # I get instead ARRAY(0x[0-9]*) or Argument "" isn't numeric in array element at ...
&lt;/code&gt;
Hoping for a revelation on the proper procedures.

</field>
</data>
</node>
