Hello All,
I am looking for any assistance possible. In a nutshell, I am looking to assign an array as a "value" in a hash, then be able to extract the array, make modifications to it, then reassign the array back to the "value" of the hash. I hope this can be done or if there is a much better way, I am definatly listening. I have included the code below and have documented exactally what I am trying to accomplish on each line.

Once again, Thank you in advanve for assistance
Gary
@fruit=(Apple, pear, Bananna, Peach); # Populate Fruit Array $new_fruit="Grapes"; # Next Fruit to be added $fruit{0}=248; # Just a random number $fruit{0}{'fruit'}=@fruit; # Want to assign array to this l +ocation in hash @HoldArray=$fruit{0}{'fruit'}; # Want to assign array at ha +sh location $fruit{0}{'fruit'} to HoldArray array push (@HoldArray,$new_fruit); # Push new_fruit to array $fruit{0}{'fruit'}=@HoldArray; # Want to assign updated fru +it array to this hash location #Print out Total fruit and list fruit print "There are $fruit{0} pieces of fruit. The following is a list of + the fruit \n"; foreach ($fruit{0}{'fruit'}) { print "$_ \n"; } exit; ==== End Script ========= ==== Begin Output ======= There are 248 pieces of fruit. The following is a list of the fruit 2 ==== End Output ======== ==== Expected Output ==== There are 248 pieces of fruit. The following is a list of the fruit Apple pear Bananna Peach Grapes ==== End Expected Output ====

In reply to Array in a Hash by g_speran

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!
  • 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, details, 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, summary, 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.