1、整型
PERL最常用的简单变量,由于其与其它语言基本相同,不再赘述。
例:
$x = 12345;
if (1217 + 116 == 1333) {
# statement block goes here
}
2、8进制和16进制数
8进制以0打头,16进制以0x打头。
例:$var1 = 047; (等于十进制的39)
$var2 = 0x1f; (等于十进制的31)
3、字符串
惯用C的程序员要注意,在PERL中,字符串的末尾并不含有隐含的NULL字符,NULL字符可以出现在串的任何位置。
. 双引号内的字符串中支持简单变量替换,例如:
$number = 11;
$text = "This text contains the number $number.";
则$text的内容为:"This text contains the number 11."
Escape Sequence Description
\a Bell (beep)
\b Backspace
\cn The Ctrl+n character
\e Escape
\E Ends the effect of \L, \U or \Q
\f Form feed
\l Forces the next letter into lowercase
\L All following letters are lowercase
\n Newline
\r Carriage return
\Q Do not look for special pattern characters
\t Tab
\u Force next letter into uppercase
\U All following letters are uppercase
\v Vertical tab
\L、\U、\Q功能可以由\E关闭掉,如:
$a = "T\LHIS IS A \ESTRING"; # same as "This is a STRING"
perl 2.1
最新推荐文章于 2022-12-26 08:38:59 发布