gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:42:37 24 4
gpt4 key购买 nike

为什么“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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com