Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: unshift single scalar

by LanX (Saint)
on Aug 10, 2014 at 02:18 UTC ( [id://1096883]=note: print w/replies, xml ) Need Help??


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 ☆☆☆☆ :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1096883]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found