my $code = 'default'; my $hash = {"1"->'ENABLE', "2"->'DISABLE'}; # Call function foo with the scalar my $ret = foo($code); # Call function foo with the hash $ret = foo($hash); sub foo(){ $param = shift; # If $param is a scalar # Do something # Else # Do something }