1
my %result = "\\path\tfolder\file.txt";

如何在不添加“\”的情况下忽略 \t 转义序列。有没有类似的东西:

my %result = r"\\path\tfolder\file.txt";

以上不起作用。

4

1 回答 1

2

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.

于 2013-07-31T10:13:23.513 回答