小编Nun*_*cio的帖子

如果在初始哈希定义中没有定义哈希键,有没有办法使perl编译失败?

使用的所有密钥都应存在于初始%哈希定义中.

use strict;
my %hash = ('key1' => 'abcd', 'key2' => 'efgh');
$hash{'key3'} = '1234'; ## <== I'd like for these to fail at compilation. 
$hash{'key4'}; ## <== I'd like for these to fail at compilation.
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

perl hash compiler-errors

4
推荐指数
2
解决办法
139
查看次数

标签 统计

compiler-errors ×1

hash ×1

perl ×1