in reply to Context aware functions - best practices?
Hm. My first reaction is to consider the possibility of:
my $x = foo(1,2,3,5);
This should of course be a scalar result, and not equal to scalar (@x = foo(1,2,3,5)). I'd feel uncomfortable omitting the results from the 2,3 and 5, so I'd probably do one of the following:
return wantarray ? @arr : "@arr"; return wantarray ? @arr : \@arr;
depending on use, 'yadda'x3. Perhaps, if it really suits the particular sub, you might want to return a join, but I'd personally be leery of that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Context aware functions - best practices?
by Aristotle (Chancellor) on Jan 14, 2003 at 18:59 UTC | |
by LAI (Hermit) on Jan 14, 2003 at 21:50 UTC | |
by Aristotle (Chancellor) on Jan 14, 2003 at 23:32 UTC | |
by LAI (Hermit) on Jan 15, 2003 at 14:33 UTC |