Jea*_*ean 2 string perl escaping character
是否有一种简单的方法,使用子程序,可以在Perl中打印字符串而不必转义每个特殊字符?
这就是我想要做的:
print DELIMITER <I don't care what is here> DELIMITER
Run Code Online (Sandbox Code Playgroud)
因此,如果我可以将字符串作为分隔符而不是特殊字符,那么显然会很棒.
perldoc perlop,在"Quote and Quote-like Operators"下,包含您需要的一切.
虽然我们通常将引号视为文字值,但在Perl中它们充当运算符,提供各种插值和模式匹配功能.Perl为这些行为提供了常规引号字符,但也提供了一种为其中任何一个选择引号字符的方法.在下表中,"{}"表示您选择的任何分隔符对.
Run Code Online (Sandbox Code Playgroud)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) <<EOF here-doc yes* * unless the delimiter is ''.