Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Returning a tied scalar

by diotalevi (Canon)
on Apr 16, 2005 at 17:09 UTC ( [id://448486]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://448486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-23 14:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found