I'm confused a bit; the thing that would help me to understand your question is knowing what's in @temp.

I take it from your description you want your push to add *one thing* to your array, and that one thing is an anonymous array, the members of which are an array slice of @temp. What you're getting is a list of anonymous arrays.

So let's make an assumption, shall we? Here's some code that might help illustrate something (what, exactly, it illustrates is left as an exercise for the reader):

my @temp = ('bob', ['carol', 'ted'], 'alice', ['felicity', 'austin'], +'arturo'); my @rows; push @rows, @temp[1..3]; # @rows is now (['carol', 'ted'], 'alice', ['felicity', 'austin']) # do something with that @rows= (); push @rows, [ @temp[0..2] ]; # @rows is now (['bob', ['carol', 'ted'], 'alice'])

But a lot could depend on how you made @temp; let me remind you that taking a reference to a literal list gives you a list consisting of the references to the elements of that list.

my @temp = \('foo', 'bar'); # @temp now (['foo'], ['bar']), not (['foo', 'bar'])

I don't know that anything like that is going on here, but remember :garbage in, garbage out. Check the input when the output's not what you expect.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


In reply to Re: passing elements of an array as a ref to another array by arturo
in thread passing elements of an array as a ref to another array by elusion

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.