I have a bunch of calls to the same function. The function ultimately prints to STDOUT. I want to change the function to return a string rather than print it. So that I can say:
print function(); # prints the string that function returns.
Easy enough. But instead of putting the print before the funtion call, I would like to simply say:
funtion(); # prints string since not assigned
$value = funtion(); # Does not print. $value holds the return string.
In other words, I want function() to know the context in which it is called, so that it knows whether to print a string or to return one. And I don't want to use IO::Scalar.
Is this possible?