http://www.perlmonks.org?node_id=11132503


in reply to Re^2: do $n exist in grep?
in thread do $n exist in grep?

I use a similar idiom in formulating a return responses or external calls, sometimes:

my ($stdout, $stderr, $ret) = capture { system('foo', ($somearg ? ('--somearg' => $somearg ) : ()), ($otherarg ? ('--otherarg' => $otherarg) : ()), ); };

...or...

return { status => $s, ($optional_field ? (optional_field => $optional_field) : ()), };

Caveat emptor. The need to do either of these may constitute code smell, but sometimes purity has to give way to get it done-ery.


Dave