Subject: | Buggy ->content method in array context |
There is a very annoying problem with the content() method in array context.
This 2 rows will end in a "Can't use string ("my content") as an ARRAY ref while "strict refs" in use at /usr/local/share/perl5/XML/Smart.pm line 1423.":
use XML::Smart;
print XML::Smart->new('<foo>my content</foo>')->{foo}->content;
As a quick fix I would suggest to replace this code at the end of the content() sub:
if( wantarray ) {
return @{ $content_to_return } ;
} else {
return $content_to_return ;
}
with this one:
if( wantarray and ref $content_to_return eq 'ARRAY') {
return @{ $content_to_return } ;
} else {
return $content_to_return ;
}
Maybe not totally correct, but it definitely works.