I am working on a Perl code using XML::DOM.
I found in Perl help(XML::DOM::Node) stating as below.
@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
If I pass it in my function as below.
&myfunction($node->getChildNodes)
I am not getting the reference to the list.
Is there any way to get the reference with out declaring temporary scalar variable, like below.
my $tmp=$node->getChildNodes;
&myfunction($tmp)
Thank you.
The second avoids creating a new array and a new reference, but the first might be clearer.
PS — Why are you telling Perl to ignore the prototype on
myfunction? Don’t use&.