We don't bite newbies here... much | |
PerlMonks |
Re: can sub check context for lvalue vs rvalue context?by ikegami (Patriarch) |
on May 11, 2018 at 20:04 UTC ( [id://1214400]=note: print w/replies, xml ) | Need Help?? |
It's not clear what you are asking, but the comments make me think the goal is to avoid returning expensive tied variables when not necessary. This is what substr, keys, vec and $#a do. The catch is these are ops, so they can simply do
For a sub, you'd need to locate the op that called the sub first. Contextual::Return can do this for you.
But does this actually speed things up? That's for you to find out. By the way, there are lighter types of magical variables than tied variables that can be used here.
In Section
Seekers of Perl Wisdom
|
|