为什么在Perl中最后一个叫’last’?

最后一个被称为Perl的历史原因是什么,而不是在C中被打破?

Perl的设计受到C(除了awk,sed和sh-下面的手册页)的影响之外,所以一定有一些推理背后不熟悉的C风格命名的break / last.

从Perl 1.000(1987年12月18日发布)手册页的一点历史:

[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.)

解决方法

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

另外,拉里·沃尔也有点奇怪.你看过他的照片吗?

Larry Wall http://www.wired.com/images/article/full/2007/12/larry_wall_250px.jpg

相关文章

1. 如何去重 #!/usr/bin/perl use strict; my %hash; while(...
最近写了一个perl脚本,实现的功能是将表格中其中两列的数据...
表的数据字典格式如下:如果手动写MySQL建表语句,确认麻烦,...
巡检类工作经常会出具日报,最近在原有日报的基础上又新增了...
在实际生产环境中,常常需要从后台日志中截取报文,报文的形...
最近写的一个perl程序,通过关键词匹配统计其出现的频率,让...