perl - 为什么 'say "%hash"' 的工作方式与它对标量和数组的工作方式不同?

标签 perl

为什么“say "%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

最佳答案

因为它会搞砸 printf 语法?

%d = ('key' => 'value');
printf "The answer is %d\n", 4;    # is %d a format symbol or the hash table?

关于perl - 为什么 'say "%hash"' 的工作方式与它对标量和数组的工作方式不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4682413/

相关文章:

perl - 如何确定 Perl 警告的位置 - 插入后在哈希上使用each()

perl - 从 Perl 脚本内部在 alpine linux 上的 zsh 上获取 `Can' t exec "command"` 错误

perl - Perl SSH到设备

sql - 从 DBIx::Class 中的多个表中选择

perl - 当我使用模块时如何找到 Perl 加载的文件?

arrays - 无法解决的 Perl 错误?

Perlbrew 无法运行 Fatalized/autodying system() 所需的简单脚本 IPC::System::Simple

perl - 为什么我的Perl map 不返回任何内容?

mysql - perl DBI mysql 在 LIMIT 子句中绑定(bind)变量

string - 在 Perl 中如何将字符串转换为数字?