...every construct that can be written with a goto can be written more clearly without one.
Try to rewrite
TheDamian's
Switch without the key
goto $__; I dare you. Until you can do it, you haven't demonstrated that everything that can be written with a
goto can be written without one (let alone written more clearly).
More generally read the thread at
(Ovid) Re: Re (tilly) 2: Paradigm Shift - Don't use strict to find out my opinion on when it is justified.
The paper of Knuth's that was referred to there gives several other good reasons to use
goto in at least some languages. Most of them boil down to the observation that there are many algorithms that can more efficiently be written with
goto than without. At least in some languages.
But not in Perl. A theorem that Knuth refers to from the literature is that any flow of control that can be achieved with
goto can be achieved with nested loops and named loop control. Therefore in Perl you need extraordinary reasons to really need
goto. (
TheDamian had an example that I believe to be exactly that extraordinary.)
Incidentally at
Re: Re (tilly) 4: Paradigm Shift - when to use goto you will find a pre-processor macro from
TheDamian showing you how to get named loops in C++. It uses
goto, but considering that its purpose is to replace
gotos that people write by hand with a more structured alternative, you may appreciate it.
UPDATE: I just checked. It seems that
TheDamian renamed $__ at some point. He now has labels named "C_A_S_E_$casecounter" instead.