in reply to Re^3: check for wantarray?
in thread check for wantarray?

IMHO missed the OP's crucial question:

How can I distinguish both if the the array has only one element, a reference of an array?

Replies are listed 'Best First'.
Re^5: check for wantarray?
by CountZero (Bishop) on Dec 29, 2008 at 17:14 UTC
    One cannot, for the simple reason that no array is ever returned by a sub. A sub returns a list and a single element list is indistinguishable from a scalar (and as you know a scalar can also contain a reference or an object, which is just a blessed reference). IMHO the question is therefore irrelevant.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James