sub execSubroutine { my $sub = shift; my @sub_ret = &{$sub}(@_); # Return an list if we get a list with more than one value # this will satisfy callers expecting lists and/or hashes return @sub_ret if (@sub_ret > 1); my $rval = $sub_ret[0]; # If we have a ref de-reference and return. if (my $type = ref($rval)) { return @$rval if ($type eq 'ARRAY'); return %$rval if ($type eq 'HASH'); } # If not a ref and the caller wants a list, give it to them if (wantarray) { return @sub_ret; } # Otherwise return a scalar return $rval; } #### sub execSubroutine { my $sub = shift; my (@array, $scalar); if (wantarray) { @array = &{$sub}(@_); return @array if (@array != 1); $scalar = $array[0]; } else { $scalar = &{$sub}(@_); } my $rval = $scalar; # If we have a ref de-reference and return. if (my $type = ref($rval)) { return @$rval if ($type eq 'ARRAY'); return %$rval if ($type eq 'HASH'); } # Otherwise return a scalar return $rval; }