in reply to How to detect a returns value gracefully

IMHO, a function that can return an array, a scalar, a reference to an array or a reference to a scalar is probably not well designed and is a candidate to be reformulated

BTW, the code you posted could be better written using wantarray inside the function

sub my_fun { # blah, blah, return wantarray ? @array : $scalar; }

Hope this helps

citromatik