in reply to How much can a function know about the context in which it is called?
see wantarray.sub function { defined wantarray ? $string : print $string }
update: I used defined so can also do
this does prevent you from checking print()'s return code, though.my $string = function();
|
|---|