in reply to Force 'sub' return to be treated in list context?

Just do something like

return wantarray ? @output : $output[0];

Replies are listed 'Best First'.
Re^2: Force 'sub' return to be treated in list context?
by flexvault (Monsignor) on Apr 04, 2012 at 10:33 UTC

    moritz,

    I have never used 'wantarray', but I will now. I looked all over for something like 'scalar', but for lists. I like the comment in the Camel book, '...should really have been named "wantlist"...'

    I'm going to put it in the code, so I will remember how to use it, but the sub 'UnPackOne' is faster for 1 element. I still wanted to know how to return a list of one.

    Thank you

    "Well done is better than well said." - Benjamin Franklin