in reply to Scalar and void subroutines
There must be something more here eff_i_g for it to be important to distinguish between void and scalar context.
Your sample code doesn't distinguish between void and scalar context of course. It simply provides a (somewhat hacky) way of signaling to the sub that you don't want a value returned. You could do something similar in a rather more up front way by:
do_something_to(\$this_var, 'No return required'); sub do_something_to { if (! $#_) { $$_[0] = 'x'; return; } return 'x'; }
but that's pretty ugle really :).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Scalar and void subroutines
by eff_i_g (Curate) on Nov 10, 2005 at 21:29 UTC | |
by GrandFather (Saint) on Nov 10, 2005 at 21:35 UTC |