Skip to Content
Perl语言入门
book

Perl语言入门

by Randal L. Schwartz, brian d foy, Tom Phoenix
August 2018
Beginner to intermediate
382 pages
7h 14m
Chinese
Southeast University Press
Content preview from Perl语言入门
标量数据
47
比较字符串时,
Perl
有一系列的字符串比较操作符,看起来像是些奇怪的短语:
lt
le
eq
ge
gt
以及
ne
。它们会逐一比对两个字符串里的字符,判定它们是否彼此相
等或是哪一个排在前面。请注意,字符在
ASCII
编码或者
Unicode
编码中的顺序并不
总是对应于字符本身意义上的顺序。至于如何修正,可以参考第
14
章。
完整的比较操作符(用于数字及字符串的比较)列在表
2-3
2
-
3
:数字与字符串的比较操作符
比较
数字
字符串
相等
== eq
不等
!= ne
小于
< lt
大于
> gt
小于或等于
<= le
大于或等于
>= ge
来看几个用到这些比较操作符的表达式:
35 != 30 + 5 #
35 == 35.0 #
'35' eq '35.0' #
假(当成字符串来比较)
'fred' lt 'barney' #
'fred' lt 'free' #
'fred' eq "fred" #
'fred' eq 'Fred' #
' ' gt '' #
if
控制结构
学会如何比较两个值后,可以根据比较结果决定下一步流程。和其他程序语言一样,
Perl
也有
if
条件语句,只要条件式为真,就执行语句块中的内容:
if ($name gt 'fred') {
print "'$name' comes after 'fred' in sorted order.\n";
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

计算机科学导论:跨学科方法

计算机科学导论:跨学科方法

罗伯特 塞奇威克, 凯文 韦恩
Perl语言入门(第8版)

Perl语言入门(第8版)

Randal L. Schwartz, brian d foy, Tom Phoenix

Publisher Resources

ISBN: 9787564177911