Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>First</strong>, the exact <strong>method</strong> of doing what you are proposing seems technically impossible:</p> <ol> <li><p>Tied variables have the <a href="http://perldoc.perl.org/perltie.html" rel="nofollow noreferrer">tie</a> attached to the variable itself, not to its value.</p></li> <li><p>In Perl, subroutine's return values are returned <strong>by value</strong>, meaning you take the value passed to <code>return</code>, access it (in you case, accessing the tied variable and calling <code>FETCH</code> in the process) - <strong>and then copy that value</strong>! Which means that what the caller gets is a scalar VALUE, not a scalar variable (tied or untied). </p></li> </ol> <p>Your confusion, in short, seems to stem from mixing together variables (locations in program's symbol table) and values stored in those variables.</p> <hr> <p><strong>Second</strong>, you were somewhat unclear as to what exactly you are trying to <strong>achieve</strong>, so it's hard to propose how to achieve what you want. But assuming, based on your description, that you wanted to call some method upon subroutine's return (possibly passing it the return value), you CAN do that.</p> <p>To do so, you need to employ what fancy people call <a href="https://stackoverflow.com/questions/2933438/simulating-aspects-of-static-typing-in-a-duck-typed-language"><em>aspect</em> programming</a>. The politically (and technically) correct way of doing it in Perl is by using Moose. </p> <p>However, you can DIY it, by basically replacing the original method with a wrapper method.</p> <p>The exact mechanics of both Moose and DIY approaches can be seen in the first two answers to the following SO question, so I won't copy/paste them here, hope you don't mind:</p> <p><a href="https://stackoverflow.com/questions/2933438/simulating-aspects-of-static-typing-in-a-duck-typed-language">Simulating aspects of static-typing in a duck-typed language</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload