小编Ihs*_*wer的帖子

无法在perl中的子例程的哈希中触发子例程

嗨,我对perl很新.我有一个包含子程序的perl哈希.我试图以我在网上找到的各种方式运行它.但似乎没有任何效果.我的代码:

%hashfun = (

start=>sub { print 'hello' },
end=>sub { print 'bye' } 

);
Run Code Online (Sandbox Code Playgroud)

我尝试了以下等等.

print "\n $hashfun{start} \n";
Run Code Online (Sandbox Code Playgroud)

这导致以下输出:

代码(<HexaDecimal Value>)

然后我试了一下

print "\n $hashfun{start}->() \n";
Run Code Online (Sandbox Code Playgroud)

这导致以下结果

代码(<HexaDecimal Value>) - >()

怎么修?

perl subroutine dereference perl-hash

1
推荐指数
1
解决办法
65
查看次数

标签 统计

dereference ×1

perl ×1

perl-hash ×1

subroutine ×1