Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Returning a tied scalar

by nobull (Friar)
on Apr 16, 2005 at 13:09 UTC ( [id://448456]=note: print w/replies, xml ) Need Help??


in reply to Returning a tied scalar

I don't like the way you have to declare a checked variable:
$intfactory->Monitor(\ my $var) = 42;

Yes that's ugly. You can at least get rid of the backslash. $_[1] paseed to the method is an alias to $var so \$_[1] is \$var.

Note also that the value of a scalar assignment is itself an lvalue.

sub Monitor : lvalue { my CheckFactory $self = shift; my $rvar = \shift; my $lvar = $$rvar; tie $$rvar, 'Checkee', $self->{Closure}; $$rvar = $lvar; $$rvar; } $intfactory->Monitor(my $var = 42);

If you want more syntactic sugar then take a look at attributes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2024-04-25 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found