sub some_func { my ($args) = @_; # if $args is a scalar, then make it an array ref $args = [$args] unless ref $args eq 'ARRAY'; # now process foreach my $arg (@$args) { # do stuff } } # sample calls: some_func($one_item); some_func([qw(bunch of items)]);