in reply to Returning a tied scalar
The general solution for lvalue subroutines is to use Tie::Constrained.
my $checked; tie $checked => 'Tie::Constrained', sub { defined $_[0] }, $INIT_VALUE;
The real answer is that you can't return variables. You can return values. The variable being assigned to already exists outside of the function and is a receptacle for the value that is to be returned by the right side of the assignment operation. So tough luck. You could write some compiler macro, I suppose, if you wanted.
|
|---|