#!/usr/bin/perl use 5.14.0; use strict; use warnings; sub my_splice_like_func { my ($list, $offset, $length) = @_; my @copy = @$list; return splice @copy, $offset // 0, $length // @copy - $offset; } $, = ' '; # 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"