简体   繁体   English

现在禁止标量上的实验键

[英]Experimental keys on scalar is now forbidden

I am trying to debug a Perl script that is giving me the error我正在尝试调试一个给我错误的 Perl 脚本

Experimental keys on scalar is now forbidden现在禁止标量上的实验键

This seems to be an issue my system having a newer version of perl, but was hoping some can sugegst a quick fix.这似乎是我的系统有一个较新版本 perl 的问题,但希望有人可以建议快速修复。

The line in question is有问题的行是

foreach my $elemName(keys $grammar -> {$groupName})

grammer was defined as语法被定义为

my $grammar = {};

and groupName comes from和 groupName 来自

foreach my $groupName (keys %$grammar)

I do not know much about perl, so any help would be appreciated我不太了解 perl,所以任何帮助将不胜感激

I have a similar issue with this line我对这条线有类似的问题

push($DbRef->{def_param}{$par_descr}->{dataset}, $blkDs);

with error Experimental push on scalar is now forbidden... near "$blkDs)"现在禁止对标量进行错误实验推送......在“$blkDs)”附近

I have tried some solutions I have found about dereferencing, but the syntax is very confusing to me.我已经尝试了一些我发现的关于取消引用的解决方案,但语法让我很困惑。

keys EXPR and push EXPR, LIST were introduced in 5.14 as an experimental feature. keys EXPRpush EXPR, LIST是在 5.14 中作为实验性功能引入的。

keys EXPR and push EXPR, LIST started warning in 5.20 when the concept of warnings for experimental features was introduced. keys EXPRpush EXPR, LIST在 5.20 开始警告,当时引入了实验性功能的警告概念。

keys EXPR and push EXPR, LIST were removed in 5.24 as the experiment was deemed a failure. keys EXPRpush EXPR, LIST在 5.24 中被删除,因为实验被认为是失败的。 (The design of keys EXPR is fundamentally flawed.) keys EXPR的设计存在根本性缺陷。)


To get the keys of hash, you can use keys %NAME .要获取 hash 的密钥,您可以使用keys %NAME You can also use a hash deference, such as keys %BLOCK or keys EXRP->%* .您还可以使用 hash 引用,例如keys %BLOCKkeys EXRP->%*

To get the indexes of an array, you can use keys @NAME .要获取数组的索引,您可以使用keys @NAME You can also use an array deference, such as keys @BLOCK or keys EXRP->@* .您还可以使用数组引用,例如keys @BLOCKkeys EXRP->@*

To push scalars onto an array, you can use push @NAME, LIST .要将标量推送到数组,您可以使用push @NAME, LIST You can also use an array deference, such as push %BLOCK, LIST or push EXRP->@*, LIST .您还可以使用数组引用,例如push %BLOCK, LISTpush EXRP->@*, LIST


In your case, you want在你的情况下,你想要

keys %{ $grammar -> {$groupName} }

or或者

keys $grammar -> {$groupName} -> %*   # 5.24+

and

push(@{ $DbRef->{def_param}{$par_descr}->{dataset} }, $blkDs);

or或者

push($DbRef->{def_param}{$par_descr}->{dataset}->@*, $blkDs);   # 5.24+

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM