可能重复:
What's the difference between a hash and hash reference in Perl?
您好,
试图理解perl中哈希的概念 示例代码如下:
#!/usr/bin/perl
use strict;
use warnings;
my %hash =();
%hash = ();
my $hash_ref = {};
$hash_ref->{dhg} = 'jhfkjd';
print $hash_ref->{dhg} . "\n";
$hash{abc} = 'def';
$hash{key2} = 0;
print "$hash{abc}\n";
我得到的输出为:
jhfkjd
def
我想知道我使用的$ hash_ref和%hash之间的区别是什么, 虽然我从语法上知道它。
我是perl的新手。 任何帮助都是有价值的。
谢谢&问候,
Tazim。