sub shift_list { # shift one element of @_ and return it as an array ref # PRESERVING the @_ aliasing # (if called like &shift_list we get the caller's actual @_) my $list; if(ref $_[0]) { $list = shift; unless (ref $list eq 'ARRAY') { die "Not an array ref ($list)"; } } else { # aliasing funkiness # pass aliased $_[0] to sub ref which returns a ref to it's @_ $list = ( sub {\@_} )->($_[0]); shift; # for parent } return $list; }