3.2.154 splicesplice
This function removes the elements designated by
The splice function is also handy for carving up the argument list passed to a subroutine. For example, assuming list lengths are passed before lists: sub list_eq { # compare two list values my @a = splice(@_, 0, shift); my @b = splice(@_, 0, shift); return 0 unless @a == @b; # same len? while (@a) { return 0 if pop(@a) ne pop(@b); } return 1; } if (list_eq($len, @foo[1..$len], scalar(@bar), @bar)) { ... } It would probably be cleaner just to use references for this, however. |
|