use 5.14.0; use warnings; sub my_splice_like_func { my ($list, @args) = @_; my @copy = @$list; return splice @copy, @args; # this doesn't actually work :-( } $, = ' '; # just keepin' it pretty my $list = [qw< one two three four >]; say my_splice_like_func($list, 2); # want "three four"; get "two three four" say my_splice_like_func($list, 2, -1); # want "three"; get "three four" #### if (@args == 0) { return @copy; } elsif (@args == 1) { return splice @copy, $args[0]; } elsif (@args == 2) { return splice @copy, $args[0], $args[1]; } else { die("too many args"); } }