gpt4 book ai didi

perl - 后缀取消引用 say((\@a)->@*) v5.22

转载 作者:行者123 更新时间:2023-12-01 14:37:32 26 4
gpt4 key购买 nike

我已阅读有关 postfix 取消引用的内容,我想尝试一下,但我无法使这个简单的示例起作用。

use v5.22;
my @a = ('hello', 'bye', 'see you');
say((\@a)->@*);

我应该打印数组,但我得到的只是:

Array found where operator expected at hola.pl line 3, at end of line (Missing operator before ?) syntax error at hola.pl line 7, near "->@"

我的 perl 版本是:

This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi

最佳答案

可以按如下方式激活该功能:

use feature qw( postderef );
no warnings qw( experimental::postderef );

可以简化为

use experimental qw( postderef );

postderef 功能也被 use feature ':5.24'; 激活(因此被 use v5.24; 激活),但是use feature ':5.20';use feature ':5.22'; 都不会激活它(因此 use v5.20;也不 use v5.22;),因为该功能在 5.20 和 5.22 中仍处于试验阶段。

该功能在 5.20 和 5.24 之间没有变化,因此在 5.20 和 5.22 中使用是安全的,因此忽略警告是安全的。

关于perl - 后缀取消引用 say((\@a)->@*) v5.22,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54645772/

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