note
monarch
The big difference between [perldoc://last] and [perldoc://next] is that those functions give deterministic answers to the compiler as to code flow. On the other hand [perldoc://goto] <i>may</i> not offer as clear an indication of the target; although given a label the compiler <i>may</i> be able to work out whether the destination is outside the given closure anyway.
<p>So here's the next example, what does the following do:<code>
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" );
}
</code>
<p>Well I tried it, but the point is I didn't know what it would do before hand. If that is "<i>bragging one's ignorance</i>" 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.
<p>I do prefer to program in a manner that has a degree of portability between languages; as I said before, [perldoc://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.
739087
739123