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關(guān)閉掉,如:
$a = "T\LHIS IS A \ESTRING"; # same as "This is a STRING"
.要在字符串中包含雙引號(hào)或反斜線,則在其前加一個(gè)反斜線,反斜線還可以取消變量替換,如:
$res = "A quote \" and A backslash \\";
$result = 14;
print ("The value of \$result is $result.\n")的結(jié)果為:
The value of $result is 14.
.可用\nnn(8進(jìn)制)或\xnn(16進(jìn)制)來(lái)表示ASCII字符,如:
$result = "\377"; # this is the character 255,or EOF
$result = "\xff"; # this is also 255
.單引號(hào)字符串
單引號(hào)字符串與雙引號(hào)字符串有兩個(gè)區(qū)別,一是沒(méi)有變量替換功能,二是反斜線不支持轉(zhuǎn)義字符,而只在包含單引號(hào)和反斜線時(shí)起作用。單引號(hào)另一個(gè)特性是可以跨多行,如:
$text = 'This is two
lines of text
';
與下句等效:
$text = "This is two\nlines of text\n";
.字符串和數(shù)值的互相轉(zhuǎn)換
例1:
$string = "43";
$number = 28;
$result = $string + $number; # $result = 71
若字符串中含有非數(shù)字的字符,則從左起至第一個(gè)非數(shù)字的字符,如:
$result = "hello" * 5; # $result = 0
$result = "12a34" +1; # $result = 13
.變量初始值
在PERL中,所有的簡(jiǎn)單變量都有缺省初始值:"",即空字符。但是建議給所有變量賦初值,否則當(dāng)程序變得大而復(fù)雜后,很容易出現(xiàn)不可預(yù)料且很難調(diào)試的錯(cuò)誤。
標(biāo)簽:六安 自貢 松原 石嘴山 鄂州 河北 宜春 淄博
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《perl簡(jiǎn)單變量 整型 浮點(diǎn)數(shù) 字符串》,本文關(guān)鍵詞 perl,簡(jiǎn)單,變量,整型,浮,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。