good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You missed one part of the trick. The body of an lvalue sub doesn't get executed when it is used as an lvalue. The trick works only if the last expression is an lvalue (as is trinary op). That means you do no good to shift in or copy the function arguments. $key and $self in your example are undefined when called as an lvalue. Arguments are still usable, but you need to initialize them in the last line of the sub. Here's a minimal rewrite. Note that $junk is effectively a package global variable holding the last value assigned with a not-ok $key. You can retrieve it with $foo->get_set($bad_key), but the value returned is for any $foo of the class. After Compline, In reply to Re: Experimenting with Lvalue Subs
by Zaxo
|
|