use of shift exists?

Discussion in 'Perl Misc' started by Mental Patient 0057, Jul 25, 2003.

  1. this moves one item over
    $a = shift @rray;

    is there a way to move three at a time?
    ($a, $b, $c) = shift 3things @rray?
    ($d, $e, $f, $g) = shift nowShift4Things @rray?
    Mental Patient 0057, Jul 25, 2003
    #1
    1. Advertising

  2. Mental Patient 0057

    David Bouman Guest

    Mental Patient 0057 wrote:

    > this moves one item over
    > $a = shift @rray;
    >
    > is there a way to move three at a time?


    Yes, use splice. A perldoc -f splice will explain it.

    --
    David.
    David Bouman, Jul 25, 2003
    #2
    1. Advertising

  3. In article <>, David Bouman wrote:
    > Mental Patient 0057 wrote:
    >
    >> this moves one item over
    >> $a = shift @rray;
    >>
    >> is there a way to move three at a time?

    >
    > Yes, use splice. A perldoc -f splice will explain it.


    Or, if you want to keep your array intact, an array slice:
    ($a, $b, $c) = @array[0..2];
    ($d, $e, $f) = @array[3..5];

    dha

    --
    David H. Adler - <> - http://www.panix.com/~dha/
    Looking at the cake is like looking at the future. Until you taste
    it, what do you really know? And, of course, by then, it's much too
    late. - Merlin, Excalibur
    David H. Adler, Jul 25, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roberto Gallo

    Shift - byte[] buf shift

    Roberto Gallo, Jan 27, 2004, in forum: Java
    Replies:
    3
    Views:
    2,024
    Thomas Schodt
    Jan 27, 2004
  2. Wenjie
    Replies:
    3
    Views:
    1,019
    Ron Samuel Klatchko
    Jul 11, 2003
  3. Santosh Nayak

    Left Shift / Right Shift Operators

    Santosh Nayak, Nov 30, 2006, in forum: C Programming
    Replies:
    16
    Views:
    1,431
    CBFalconer
    Nov 30, 2006
  4. Sanny
    Replies:
    38
    Views:
    3,345
    Thomas Richter
    Apr 29, 2011
  5. devphylosoff

    what "shift" does, if not "$_ = shift;" ?

    devphylosoff, Nov 29, 2007, in forum: Perl Misc
    Replies:
    3
    Views:
    315
    Michele Dondi
    Dec 4, 2007
Loading...

Share This Page