如何在perl中直接将唯一哈希键分配给标量
是否可以将唯一现有的哈希键直接分配给标量 例如,这两条语句可以合并为一条吗如何在perl中直接将唯一哈希键分配给标量,perl,hash,syntax,scalar,Perl,Hash,Syntax,Scalar,是否可以将唯一现有的哈希键直接分配给标量 例如,这两条语句可以合并为一条吗 @the_keys = keys %the_hash; # a hash with a single key $the_sole_key = shift @the_keys; 已在前面的代码中验证%u散列中是否存在单个密钥 提前谢谢 my ($key) = keys(%hash); 或 或 my $key = ( keys(%hash) )[0];
@the_keys = keys %the_hash; # a hash with a single key
$the_sole_key = shift @the_keys;
已在前面的代码中验证%u散列中是否存在单个密钥
提前谢谢
my ($key) = keys(%hash);
或
或
my $key = ( keys(%hash) )[0];