The big difference between
last and
next is that those functions give deterministic answers to the compiler as to code flow. On the other hand
goto may not offer as clear an indication of the target; although given a label the compiler
may be able to work out whether the destination is outside the given closure anyway.
So here's the next example, what does the following do:
for ( my $i = 0; $i < 10; $i++ ) {
my $j = $i;
if ( $i == 5 ) { goto nextpoint; }
}
for ( my $k = 0; $k < 10; $k++ ) {
my $m = $k;
nextpoint:
print( "$m\n" );
}
Well I tried it, but the point is I didn't know what it would do before hand. If that is "bragging one's ignorance" then so be it. Rightly or wrongly I came from a C background where if you tried risky behaviour like this you got into real trouble. Perl is far more forgiving.
I do prefer to program in a manner that has a degree of portability between languages; as I said before, goto is risky: if you consider yourself an expert in the language at the time and the compiler behaviour and implications (if any) to the stack then by all means go ahead. I'll stick to what I know is safe.