为什么'说“%hash”'与标量和数组的工作方式不同?
#!/usr/bin/perl
use strict;
use warnings;
use Modern::Perl;
use Test::More;
my $s = "Hello, World!";
say $s;
say "$s";
my @a = ("Hello", "World!");
say @a;
say "@a";
my %h = ("Hello", "World!");
say %h;
say "%h";
D:\TEST\perl>perl 1.pl
Hello, World!
Hello, World!
HelloWorld!
Hello World!
HelloWorld!
%h
答案 0 :(得分:7)
因为它会搞砸printf
语法?
%d = ('key' => 'value');
printf "The answer is %d\n", 4; # is %d a format symbol or the hash table?
答案 1 :(得分:6)
简短的回答很简单“因为就是这样。” Sigil%不会在双引号字符串中触发插值。
我没有明确的合理化,但它可能是以下的混合: