@array = qw(one two three four five six seven eight);
<Some command here>
print @array;
Here are a few ways, in increasing order of dumbness:
Using a slice:
@array = @array[ 5 .. $#array ];
Using splice
:
splice @array, 0, 5;
Using shift
:
shift @array for 1..5;
Using grep
:
my $cnt = 0;
@array = grep { ++$cnt > 5 } @array;
Using map
:
my $cnt = 0;
@array = map { ++$cnt < 5 ? ( ) : $_ } @array;
I'm sure far better hackers than I can come up with even dumber ways. :)
You are looking for the splice builtin:
splice @array, 0, 5;
splice @array, 0, 5;
will do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With