perl 回调必须是函数引用

[root@wx03 lib]# cat a1.pl
use AE;
use AnyEvent;
##定义watch
my $t = AnyEvent->timer(
after => 0,
interval => 5,
cb => sub {print test."\n";}
);
##不要再每秒打印时间
##undef $t;
my $cv = AnyEvent->condvar;
$cv->recv;
[root@wx03 lib]# perl a1.pl
test
test [root@wx03 lib]# cat a1.pl
use AE;
use AnyEvent;
##定义watch
my $t = AnyEvent->timer(
after => 0,
interval => 5,
cb => print test."\n"
);
##不要再每秒打印时间
##undef $t;
my $cv = AnyEvent->condvar;
$cv->recv;
[root@wx03 lib]# perl a1.pl
test
1: callback must be a CODE reference or another callable object at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/AnyEvent/Impl/EV.pm line 50. 回调必须是一个函数引用或者而另外的回调对象
上一篇:postman笔记1--postman的安装教程


下一篇:【转】jQuery最佳实践