#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; my %source; my @array = (10 .. 12); $source{'data'} = \@array; print "\n".'%source'." - from main\n". Dumper %source; push (@ { $hash{"foo"}{"bar"} } , addSomeNumbers(1,3) ); print "\n".'%hash'." - from main\n". Dumper %hash; push (@ { $hash{"foo"}{"bar"} } , addSomeNumbers(4,6) ); print "\n".'%hash'." - from main\n". Dumper %hash; push (@ { $hash{"foo"}{"bar"} } , addSomeNumbersVia2ndSub(7,9) ); print "\n".'%hash'." - from main\n". Dumper %hash; push (@ { $hash{"foo"}{"bar"} } , @{ (addSomeNumbersFromSource("data") +)[0] } ); print "\n".'%hash'." - from main\n". Dumper %hash; sub addSomeNumbers{ my ($start, $end) = @_; my @array = ($start .. $end); print "\n".'@array'." - from addSomeNumbers\n". Dumper @array; return @array; } sub addSomeNumbersVia2ndSub{ my ($start, $end) = @_; my @array = addSomeNumbers($start, $end); print "\n".'@array'." - from addSomeNumbersVia2ndSub\n". Dumper @a +rray; return @array; } sub addSomeNumbersFromSource{ my ($data) = @_; my @array = $source{$data} ; return @array; }

In reply to Re: Pushing Arrays into Hash without nesting by tybalt89
in thread Pushing Arrays into Hash without nesting by treeshark

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.