jacques has asked for the wisdom of the Perl Monks concerning the following question:
Easy enough. But instead of putting the print before the funtion call, I would like to simply say:print function(); # prints the string that function returns.
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.funtion(); # prints string since not assigned $value = funtion(); # Does not print. $value holds the return string.
Is this possible?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How much can a function know about the context in which it is called?
by friedo (Prior) on Jul 29, 2005 at 20:07 UTC | |
|
Re: How much can a function know about the context in which it is called?
by Joost (Canon) on Jul 29, 2005 at 20:07 UTC | |
|
Re: How much can a function know about the context in which it is called?
by ikegami (Patriarch) on Jul 29, 2005 at 20:08 UTC | |
|
Re: How much can a function know about the context in which it is called?
by Corion (Patriarch) on Jul 29, 2005 at 20:12 UTC | |
|
Re: How much can a function know about the context in which it is called?
by jacques (Priest) on Jul 29, 2005 at 20:27 UTC | |
|
Re: How much can a function know about the context in which it is called?
by brian_d_foy (Abbot) on Jul 30, 2005 at 18:33 UTC |