Why is 'last' called 'last' in Perl?

The term 'last' makes more sense when you remember that you can use it with more than just the immediate looping control. You can apply it to labeled blocks one or more levels above the block it is in:

 LINE: while( <> ) {
      WORD: foreach ( split ) {
           last LINE if /^__END__\z/;
           ...
           }
      }

It reads more naturally to say "last" in english when you read it as "last line if it matches ...".


I expect that this is because Perl was created by a linguist, not a computer scientist. In normal English usage, the concept of declaring that you have completed your final pass through a loop is more strongly connected to the word "last" ("this is the last pass") than to the word "break" ("break the loop"? "break out of the loop"? - it's not even clear how "break" is intended to relate to exiting the loop).


The semantics of 'break' or 'last' are defined by the language (in this case Perl), not by you.

Why not think of 'last' as "this is the last statement to run for the loop".

It's always struck me as odd that the 'continue' statement in 'C' starts the next pass of a loop. This is definitely a strange use of the concept of "continue". But it is the semantics of 'C', so I accept it.

By trying to map particular programming concepts into single English words with existing meaning there is always going to be some sort of mismatching oddity

Source

Plus, Larry Wall is kinda weird. Have you seen his picture?

Larry Wall
(source: wired.com)