Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: I am confused by a "Learning Perl" sample showing "unshift"

by LanX (Sage)
on Jan 22, 2021 at 22:41 UTC ( #11127314=note: print w/replies, xml ) Need Help??


in reply to Re^2: I am confused by a "Learning Perl" sample showing "unshift"
in thread I am confused by a "Learning Perl" sample showing "unshift"

For reasons of symmetry this

unshift @a, @b means @a = ( @b, @a )

Much the same way as

push @a, @b means @a = ( @a, @b )

So no implicit reversing of @b.

HTH :)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^4: I am confused by a "Learning Perl" sample showing "unshift"
by rsFalse (Chaplain) on Jan 23, 2021 at 21:48 UTC
    Therefore:
    unshift @a, @b same* as  push @b, @a

    *But see clarification from choroba:
      :-)

      No, as the first one changes @a, but the second one changes @b. The result is the same, but ends up in a different container.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
      Yes good point! :)

      ( provided choroba's comment, that the targets are swapped. )

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2022-10-04 16:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (18 votes). Check out past polls.

    Notices?