perl 函数回调 引用$client->run(sub {$client->sync});
来源:互联网 发布:黑客帝国4矩阵复活 云 编辑:程序博客网 时间:2024/05/11 01:59
匿名函数引用:[root@wx03 wx]# perl a1.pl CODE(0x2077b30)test[root@wx03 wx]# cat a1.pl $ref= sub {return test."\n"};print $ref;print "\n";print &$ref;[root@wx03 wx]# perl a1.pl CODE(0x21a2b30)testmy $eventloop=$client->run(sub {print "test\n";}); sub {print "test\n";} 是匿名函数一个引用;[root@wx03 lib]# cat eventloop.pm package eventloop;use AE; use AnyEvent;##定义watch sub run {my $self=shift; my $code=shift; my $t = AnyEvent->timer( after => 0, interval => $self->{interval}, cb => $code ); ##不要再每秒打印时间 ##undef $t; my $cv = AnyEvent->condvar; $cv->recv;};1;cb=> 必须是函数的引用:[root@wx03 wx]# cat scan.pl use lib '/root/scanwx/lib';use Client;use Data::Dumper;my $client=Client->new();my $qrcode=$client->get_qrcode();print "\$qrcode is $qrcode\n";my $login_info=$client->login_info();my $login=$client->login();$client->run(sub {$client->sync});$str=Dumper($client);print "\$str is $str\n"[root@wx03 lib]# cat sync.pm package sync;sub sync { my $self=shift; print "test\n";};1;
0 0
- perl 函数回调 引用$client->run(sub {$client->sync});
- perl 实现client
- client
- client
- Client
- Client
- Client
- Client
- client
- Client
- client
- Client
- client
- client
- Perl socket client and server
- perl 回调必须是函数引用
- snpp.alert - Pure perl SNPP client
- perl安装Weixin::Client 模块依赖问题
- Android 屏幕适配——关于布局文件中dp 的使用
- Unity之Invoke、InvokeRepeating、StartCoroutine学习一
- 类反射
- js 中 foreach循环(for in)中,最后会多出一个值
- hdu 1231最大连续子序列
- perl 函数回调 引用$client->run(sub {$client->sync});
- 面试:数组:区间搜索
- Android之Adapter用法总结
- 百度工程效率部-实习研发工程师一、二面
- HDU 4734--基础数位dp(递推)
- bootstrap-datetimepicker初学者经验
- Retrofit2+OkHttp3+RxJava搭建网络框架
- Ui
- MTK use GDB to debug KE by get break point in file