Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
perl XML::DOM中的返回值_Perl_List - Fatal编程技术网

perl XML::DOM中的返回值

perl XML::DOM中的返回值,perl,list,Perl,List,我正在使用XML::DOM编写Perl代码 我在Perl帮助(XML::DOM::Node)中找到如下说明 @list = $node->getChildNodes; # returns a perl list $nodelist = $node->getChildNodes; # returns a NodeList (object reference) for my $kid ($node->getChildNodes) # iterate over

我正在使用XML::DOM编写Perl代码

我在Perl帮助(XML::DOM::Node)中找到如下说明

@list = $node->getChildNodes;        # returns a perl list
$nodelist = $node->getChildNodes;    # returns a NodeList (object reference)
for my $kid ($node->getChildNodes)   # iterate over the children of $node
&myfunction($node->getChildNodes)
如果我在我的函数中传递它,如下所示

@list = $node->getChildNodes;        # returns a perl list
$nodelist = $node->getChildNodes;    # returns a NodeList (object reference)
for my $kid ($node->getChildNodes)   # iterate over the children of $node
&myfunction($node->getChildNodes)
我没有得到这份名单的参考资料

是否有任何方法可以在不声明临时标量变量的情况下获取引用,如下所示

my $tmp=$node->getChildNodes;
&myfunction($tmp)
多谢各位

myfunction([ $node->getChildNodes ])

myfunction(scalar $node->getChildNodes)
第二种方法避免创建新数组和新引用,但第一种方法可能更清晰



PS-为什么要告诉Perl忽略
myfunction
上的原型?不要使用
&

如果这回答了您的问题,请勾选它旁边的标记。欢迎来到StackOverflow!