in reply to
RE: Number of times I've used goto in Perl
in thread Number of times I've used goto in Perl
Actually, if you've ever done much module/OO programming,
you've probably used goto quite a lot, particularly if
you write AUTOLOAD functions. From perltoot:
When Perl tries to call an undefined function in a
particular package and that function is not defined,
it looks for a function in that same package called
AUTOLOAD. If one exists, it's called with the same
arguments as the original function would have had.
The fully-qualified name of the function is stored
in that package's global variable $AUTOLOAD. Once
called, the function can do anything it would like,
including defining a new function by the right name,
and then doing a really fancy kind of goto right
to it, erasing itself from the call stack.
As such goto
is used in quite a few modules, core or
otherwise. CGI.pm, for example.