Gossamer Forum
Home : General : Perl Programming :

Multiple shift();

Quote Reply
Multiple shift();
Hi,

Simple question, is it possible to remove multiple items from an array using shift? i.e. rather than using:

shift(@array);
shift(@array);
shift(@array);

...is there something like:

shift(@array,3);

???

Thanks,
adam
Quote Reply
Re: Multiple shift(); In reply to
Sure, check out the splice command. Type:

perldoc -f splice

to find out more, but to do what you want is:

splice (@array, 0, 3);

Cheers,

Alex
Quote Reply
Re: Multiple shift(); In reply to
Thanks Alex.