愚蠢的问题,但对我来说,它们似乎是相同的,但我认为应该有所不同。这三种类型的打印品之间是否有已知的区别?
类型1
print qq~ <td>....</td>~
2型
print qq|<table>....</table>|
类型3
print <<EOT
<table>...</table>
EOT
类型1和2 Quote and Quote-like Operators
虽然我们通常将引号视为文字值,但在Perl中它们充当运算符,提供各种插值和模式匹配功能。Perl为这些行为提供了惯用的引号字符,但还为您提供了一种为其中任何一种选择引号字符的方法。在下表中,{}代表您选择的任意一对定界符。
Customary Generic Meaning Interpolates
'' q{} Literal no
"" qq{} Literal yes
`` qx{} Command yes*
qw{} Word list no
// m{} Pattern match yes*
qr{} Pattern yes*
s{}{} Substitution yes*
tr{}{} Transliteration no (but see below)
y{}{} Transliteration no (but see below)
<<EOF here-doc yes*
* unless the delimiter is ''.
类型3。 Here-doc
双引号表示将使用与普通双引号字符串完全相同的规则对文本进行插值。
print <<EOF;
The price is $Price.
EOF
print << "EOF"; # same as above
The price is $Price.
EOF
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句