note
HugoNo1
<p>
Surprisingly nobody has commented on this nice use of the <code>goto</code> Function<br />
which exists <b>only in Perl</b>:
</p>
<code>
sub newFuctionName
{
#Doing the same stuff as always ...
}
sub oldFunctionName
{
goto &newFuctionName;
}
</code>
<p>
Which has the nice effect:<br />
http://perldoc.perl.org/functions/goto.html<br />
</p>
<p><i>
it exits the current subroutine (losing any changes set by local) and immediately calls in its place the named subroutine using the current value of @_ .
</i></p>
<p>
That way the Parameters won't be copied again when you go from <code>oldFunctionName()</code> to <code>newFunctionName()</code><br />
which is very useful when you use a Library in many Projects and by the time find that you should <i>rename</i> this Feature.
</p>
<p>
I also found this often in Modules as:<br />
<code>
sub _internalImplementation
{
#Doing the job ...
}
sub exportFunctionName
{
goto &_internalImplementation;
}
</code>
</p>
7947
7947