Search code examples
perlsyntaxlanguage-featureslanguage-design

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


What is the historical reason to that last is called that in Perl rather than break as it is called in C?

The design of Perl was influenced by C (in addition to awk, sed and sh - see man page below), so there must have been some reasoning behind not going with the familiar C-style naming of break/last.

A bit of history from the Perl 1.000 (released 18 December, 1987) man page:

[Perl] combines (in the author's opinion, anyway) some of the best features of C, sed, awk, and sh, so people familiar with those languages should have little difficulty with it. (Language historians will also note some vestiges of csh, Pascal, and even BASIC|PLUS.)


Solution

  • 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)