Skip to Content
Perl语言入门(第8版)
book

Perl语言入门(第8版)

by Randal L. Schwartz, brian d foy, Tom Phoenix
October 2022
Beginner to intermediate
390 pages
7h 5m
Chinese
Southeast University Press
Content preview from Perl语言入门(第8版)
22
1
在某些情况下,你可能需要在一台机器上写程序,再传送到另一台机器上运行。这个
时候,请使用“文本模式(
text mode
)”或者“
ASCII
模式(
ASCII mode
)”来传输
程序。记住,千万不能是“二进制模式(
binary mode
)”。这一步是必需的,因为即
便是文本文件,不同系统对待换行符的方式也有所不同,所以碰到无法理解的换行符
时,某些老旧的
Perl
还可能会中断运行。
一个简单的程序
按历来的习惯,任何一门根植于
Unix
文化的程序语言入门书都会以“
Hello, World
这个程序作为开头。所以,下面是它在
Perl
里面的写法:
#!/usr/bin/perl
print "Hello, world!\n
;
假设我们已经将上面两行代码输入到文本编辑器里了(暂且别管程序各部分是什么意
思,我们很快就会讨论到)。一般来说,程序可以用任何文件名保存。
Perl
程序并不
需要用什么特殊的文件名或扩展名命名,甚至能不用扩展名就最好不要用。不过,在
某些
Unix
以外的系统上也许必须使用
.
plx
(代表
PerL eXecutable
)之类的扩展名。
接下来,你可能还需要告诉系统,该文件是一个可执行程序(也就是一个命令)。不
同的系统需要的操作方式也会有所不同,也许只需要将程序文件存储到某个地方就行
了(多数时候在你当前的工作目录也行)。在
Unix
系统上,你可以使用
chmod
命令
将程序文件的属性修改为可执行,如下所示:
$
chmod a+x my_program
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Perl语言入门

Perl语言入门

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 9787576602036