get get_children方法

来源:互联网 发布:mysql递归 编辑:程序博客网 时间:2024/06/05 05:31
 get 方法:[root@wx03 zook]# cat a4.pl use ZooKeeper;use AnyEvent;use AE;use Data::Dumper;   my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');    my $stat = $zk->exists('/zk/child600');   if ($stat){              $zk->delete('/zk/child600');    }   my $created_path = $zk->create('/zk/child600', 'child600',                                   ephemeral => 1,                                    sequential => 1,                                   'acl' => ZOO_OPEN_ACL_UNSAFE);        ###获取数据    my ($data,$stat)=$zk->get('/zk');    print $data;[root@wx03 zook]# perl a4.pl Odd number of elements in hash assignment at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/ZooKeeper.pm line 392.myData[root@wx03 zook]#get_child 方法:   my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');    my $stat = $zk->exists('/zk/child600');   if ($stat){              $zk->delete('/zk/child600');    }   my $created_path = $zk->create('/zk/child600', 'child600',                                   ephemeral => 1,                                    sequential => 1,                                   'acl' => ZOO_OPEN_ACL_UNSAFE);        ###获取数据    my (@data,$stat)=$zk->get_children('/zk');    foreach (@data){    print "\$_ is $_\n";    };[root@wx03 zook]# perl a4.pl Odd number of elements in hash assignment at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/ZooKeeper.pm line 392.$_ is child500$_ is child700$_ is child600$_ is test$_ is child300$_ is child1$_ is child200获取child 子节点的值:[root@wx03 zook]# cat a4.pl use ZooKeeper;use AnyEvent;use AE;use Data::Dumper;   my $zk = ZooKeeper->new(hosts => '127.0.0.1:2181');    my $stat = $zk->exists('/zk/child600');   if ($stat){              $zk->delete('/zk/child600');    }   my $created_path = $zk->create('/zk/child600', 'child600',                                   ephemeral => 1,                                    sequential => 1,                                   'acl' => ZOO_OPEN_ACL_UNSAFE);        ###获取数据    my (@data,$stat)=$zk->get_children('/zk');    foreach (@data){    print "\$_ is $_\n";    print $zk->get("/zk/$_");    print "\n";    };[root@wx03 zook]# perl a4.pl Odd number of elements in hash assignment at /usr/local/perl/lib/site_perl/5.22.1/x86_64-linux/ZooKeeper.pm line 392.$_ is test2d4rwrHASH(0x14d0e28)$_ is child600HASH(0x14e5f38)$_ is testaaaHASH(0x14e5f38)$_ is test1dadadHASH(0x14e5f38)

0 0
原创粉丝点击