sub foo { # some stuff my $fh; if (@_ == 1) { open $fh, $_[0]; } else { open $fh, $_[0], $_[1], @_[2..$#_]; } return $fh; }