sub foo { my $first = shift; # get the first argument and remove it from @_; my $last = pop; # get the last argument and remove it from @_; }