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. :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…