我想打印出字符串的原始文本,而不插入特殊字符。因此,例如,如果我的字符串是 "hello\nthere"
,我想打印它,而不是
hello
there
字符串存储在一个变量中,我没有使用文字,所以这不仅仅是单引号还是双引号的问题(我不认为)。我该怎么做?
最佳答案
Data::Dumper
的正确咒语将执行此操作。
use Data::Dumper;
$Data::Dumper::Terse = 1;
$Data::Dumper::Useqq = 1;
$foo = "hello
there";
print Dumper $foo; # "hello\nthere"
关于string - perl:显示原始字符串,包括特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45333674/