in reply to Re: Scalar and void subroutines
in thread Scalar and void subroutines

ike:

The return here errors if called as: name(\$var)
sub name { my ($arg) = @_; if (not ref $arg) { $arg = \$arg; } # Do stuff. $$arg = 'changed'; return $$arg; }
If I remove the return $$arg; it still works in either context because of that sneaky little 'return the last value' trick :D

Thanks!