- 论坛徽章:
- 0
|
学习Perl就像当年学习五笔,有兴趣了就学一下,过一段时间没有使用就忘了,过段时间又学一下,过段时间又忘记了....
今天又开始看小骆驼书,打算好好的学习一下Perl的语法,希望以后能多使用,不要再忘记了 (:
似乎Perl的语法结合了C和shell,比如,保留了C的{}和结束语句的';'(做为一门脚本语言,用';'结束语句是一个很让我崩溃的特性),而和shell差不多简洁.
有时候感觉学习的语言一多,就容易混乱。Perl就给我制造了一些类似的麻烦。
拿Perl和Python对比学习,发现了一些让人崩溃的地方。比如, print 'a', 'b', 'c', 在perl里是输出一个list,而在Python里是输出一个tuple.
习惯了print 'hello world', 要写成print "hello world\n"; 结果不是忘记添加'\n', 就是忘记了结尾的';'。都改完了才发现还要将单引号改成双引号... )-:
其他的对比:
Perl: print "hello world"; = Python: print 'hello world',
Perl: print "hello world\n"; = Python: print 'hello world'
perl: say 'hello world'; = Python: print 'hello world'
Perl: 'abc' x 3 = Python: 'abc' * 3
perl: print 'a' . 'b' . 'c'; = Python: print 'a' + 'b' + 'c',
Perl: print 'a' . ' ' . 'b' . "\n"; = Python: print 'a', 'b'
Perl: print "hello $var\n"; = Python: print "hello", var
还有一些,就不列举了。
不管怎样,还是要坚持下去, 呵呵
[ 本帖最后由 chunchengfh 于 2009-1-9 18:21 编辑 ] |
|