As it seems silly and slow to always use:
my ($return, $code) = $sandbox->sysCommand( $cmd );
I suggest we simplify this:
my $return = $sandbox->sysCommand( $cmd );
If we don't need the return code, using wantarray we know we've been requested a scalar, so we simply send back the output.
If you disagree with this change, please let me know and I'll roll-back (and fix the few places where I've used it).
I've check the current usage of this, and it shouldn't break anything (all calls are either like above, or void.
--
OlivierRaginel - 16 Nov 2008 - 21:21
I'll take your word for it that it's faster, but the reason I personally avoid
wantarray
is code legibility.
I found context dependencies like this hell to deal with when I was learning perl, and I don't really want to put
other people in that position.
So, go ahead and make the change if it makes for better code, but comment it to death, please!
--
CrawfordCurrie - 17 Nov 2008 - 09:36
I got your points, and they make sense, a lot of sense.
I thought it was pretty obvious that wantarray had to be faster, because you're not building up the array, and then discarding some parts of it, but I got told otherwise by some perl mongers.
I'll revert my changes, and fix the 2 occurences where this was used.
For the record, I'll use:
my ( $return ) = $sandbox->sysCommand( $cmd );
or
return ( $sandbox->sysCommand( $cmd ) )[0];
--
OlivierRaginel - 17 Nov 2008 - 10:12