my %result = "\\path\tfolder\file.txt";
如何在不添加“\”的情况下忽略 \t 转义序列。有没有类似的东西:
my %result = r"\\path\tfolder\file.txt";
以上不起作用。
my %result = "\\path\tfolder\file.txt";
如何在不添加“\”的情况下忽略 \t 转义序列。有没有类似的东西:
my %result = r"\\path\tfolder\file.txt";
以上不起作用。
Single quotes process two escape sequences: \\
and \'
, so you would have to double the leading double-backslash but not the others:
my $result = '\\\\server\toppath\files';
To get what you want, you could use a here-document at the cost of some syntactic bulk.
chomp(my $result = <<'EOPath');
\\server\toppath\files
EOPath
Note the change of sigil from %
to $
because a string is a scalar, and hashes are for associations.