What I would do using an anonymous HASH reference :
#case 1, pass in hash
test({arg1 => 'test', arg2 => 'test2'});
#case 2, just pass in single values
test('test', 'test2');
sub test {
my $arg = shift;
if(ref $arg eq 'HASH') {
...;
}
#if values passed in as single values, do something else
else {
...;
}
}
See
http://perldoc.perl.org/perlref.html
http://perldoc.perl.org/perlreftut.html