in reply to Re: unshift single scalar
in thread unshift single scalar

> I do not want "push" that puts it at the bottom of the list.

That's the code you posted as demonstration of what you want

DB<108> @array = ( "Top" ); => "Top" DB<109> @output=1..3 => (1, 2, 3) DB<110> unshift (@array, @output); => 4 DB<111> @array => (1, 2, 3, "Top")

and that's what push does

DB<112> push @output, "Top" => 4 DB<113> @output => (1, 2, 3, "Top")

maybe you should check your examples before posting?

Besides: I've never heard of "bottom" or "top" of lists or even arrays. "Start" and "End" are much better description for chains w/o any vertical orientation.

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

Replies are listed 'Best First'.
Re^3: unshift single scalar
by AppleFritter (Vicar) on Aug 10, 2014 at 09:18 UTC

    Besides: I've never heard of "bottom" or "top" of lists or even arrays. "Start" and "End" are much better description for chains w/o any vertical orientation.

    It's not so uncommon when one is working with stacks: you push items onto the top of the stack, and pop them off the top again. Since this is where Perl's push and pop got their names from, the terminology is not malapropos, even if it is perhaps uncommon for general arrays and lists.

      But you are aware that now the end of the list is the top of stack (push/pop) , while the OP considers the start as such? :)

      Cheers Rolf

      (addicted to the Perl Programming Language and ☆☆☆☆ :)