use of shift exists?

  • Thread starter Mental Patient 0057
  • Start date
M

Mental Patient 0057

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?
 
D

David Bouman

Mental said:
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.
 
D

David H. Adler

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top