读 《C程序员精通Perl》http://book.douban.com/subject/1232075/ 2.1节 笔记
学习一门新语言,先写个hello world,就可以知道此语言的大概结构
#!/usr/bin/perl
use strict;
use warnings;
print "hello world\n";运行结果:
[root@localhost perl_practice]#
[root@localhost perl_practice]# chmod +x hello.pl
[root@localhost perl_practice]# perl hello.pl
hello world
[root@localhost perl_practice]# ./hello.pl
hello world
[root@localhost perl_practice]#
#!/usr/bin/perl --- 解释器文件(interpreter file)
use strict; --- 打开严格语法和变量检查
use warnings; --- 打开附加编译和运行时的告警。在perl的5.6版本之前,要在命令行使用-w进行打开,如#perl -w hello.pl
print "hello world\n"; --- 打印字符串
本文介绍了一个简单的Perl程序示例,通过实现经典的“Hello World”程序来展示Perl的基本语法特性,包括如何设置解释器路径、启用严格和警告模式,以及如何输出文本。
375

被折叠的 条评论
为什么被折叠?



