"Jeremy Morton" <> wrote in
news:41fbaeb9$0$26027$:
[ Removed comp.lang.perl from newsgroups list ]
> Probably been mentioned before but I fail to see why Perl changed the
> 'break' keyword to 'last', in loops. Bear with me on this - it seems
> semantically more accurate to say 'break' -
I have a sneaking suspicion that you are trolling, but I will indulge
you anyway. You can think of 'last' as 'this is the last statement to be
excuted in this loop'. At least, that is why it made sense to me the
first time I started learning Perl.
> 'last' makes it sound like the current loop will be the last,
Your terminology is odd. How can the current loop be the last? How could
a statement in one loop affect whether or not other loops are excuted?
Are you saying, if I have:
my @animals = qw(cat dog dino);
for my $animal (@animals) {
last if $animal eq 'dog';
}
for my $animal (@animals) {
print uc $animal, "\n";
}
The second loop will not be excuted due to the 'last' statement in the
first loop.
I am going to recommend a visit to
http://learn.perl.org/ as well as
reading perldoc -f last.
Hope this helps.
Sinan.