Subject: | Unexpected behaviour when creating nested arrays. |
Date: | Wed, 16 Apr 2008 17:00:07 +1000 |
To: | bug-RPC-XML [...] rt.cpan.org |
From: | Steve Goodwin <steveg [...] benon.com> |
The RPC::XML::array constructor behaves unexpectedly when the first
argument is an RPC::XML::array object. To test ...
$one = RPC::XML::array->new(1,2);
$two = RPC::XML::array->new(3,4);
$three = RPC::XML::array->new($one, $two); # same as $one.
With the array constructor, the problem lies within the line ...
my @args = (UNIVERSAL::isa($_[0], 'ARRAY')) ? @{$_[0]} : @_;
When $three is being constructed, the isa subroutine evaluates to true,
so the constructor dereferences the first argument ($one) to be arguments.
A workaround for this is to pass the constructor arguments in an
arrayref. Eg.
$three = RPC::XML::array->new([$one, $two]); # creates nested arrays.
Regards,
Steve