Perl 入门1

http://ind.ntou.edu.tw/~dada/cgi/Perlsynx.htm

my 是一種宣告變數的方式,它可以使變數區域化。
宣告變數時若不加 my 或 local 則Perl會把它當作全域變數使用。
習慣上,我們會將字串用雙引號括起來,而數值就不用加引號。

字符串运算符和函数:

函数(算子)意义
(str) x (int)字符串的重复叠加,类比 py 的 “str”*2 == “strstr”
(str).(str)字符串链接运算
eq,ne相等,不等;返回 T/F。 $x == $y compares two numbers for equality, and $x eq $y compares two strings.
cmpReturns -1, 0, or 1 if the left operand is stringwise less than, equal to, or greater than the right operand.

数值运算符和函数:

函数(算子)意义
< = >Returns -1 if the left operand is less than the right, +1 if is it greater than, and 0(False) otherwise.

符号规约

(算子)意义
<> and while(<>)is explained in perlop (the latter is also explained in perlvar). <> is called the “null file handle”. It is a special construct and does not just mean <STDIN>
~~ smart matching operator见引用一

引用一

perl智能匹配操作符~~
What’s the use of <> in Perl?

%a ~~ %b            哈希的键是否一致
%a ~~ @b            至少%a中的一个键在列表@b之中
%a ~~ /Fred/        至少一个键匹配给定的模式
%a ~~ 'Fred'        哈希中某一指定键$a{Fred}是否存在
@a ~~ @b            数组是否相同
@a ~~ /Fred/        至少有一个元素匹配给定的模式
@a ~~ 123           至少有一个元素转化为数字后是123
@a ~~ 'Fred'        至少有一个元素转化为字符串后是'Fred'
$name ~~ undef      $name确实尚未定义
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值