in reply to How much can a function know about the context in which it is called?

print() enforces list context on the function, so you can do
sub function { defined wantarray ? $string : print $string }
see wantarray.

update: I used defined so can also do

my $string = function();
this does prevent you from checking print()'s return code, though.