#!/usr/bin/perl sub foo { $#_ = 3 if @_ > 3; # limit to 4 args print "$_\n" for @_; print "---\n"; } foo(1,2,3); foo(1,2,3,4); foo(1,2,3,4,5); __END__ 1 2 3 --- 1 2 3 4 --- 1 2 3 4 ---