$ program3_3
first value is 0
second value is 0.01
三、字符串
惯用C的程序员要注意,在PERL中,字符串的末尾并不含有隐含的NULL字符,NULL字符可以出现在串的任何位置。
. 双引号内的字符串中支持简单变量替换,例如:
$number = 11;
$text = "This text contains the number $number.";
则$text的内容为:"This text contains the number 11."
.双引号内的字符串中支持转义字符
Table 3.1. Escape sequences in strings.
Escape SequenceDescription\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"
.要在字符串中包含双引号或反斜线,则在其前加一个反斜线,反斜线还可以取消变量替换,如:
$res = "A quote \" and A backslash \\";