I wish to avoid the testing in the calling function.
Then add the testing to the called function:
sub createOwner { if (0.5 > rand) { return ('XML::LibXML::Text'->new('John Smith')) } else { my $ret = 'XML::LibXML::Element'->new('href'); $ret->appendTextNode('http://johnsmith.com'); return ($ret) } }
Update: Fixed a warning.
In reply to Re: XML::LibXML creating nodes with a string OR a node
by choroba
in thread XML::LibXML creating nodes with a string OR a node
by worik
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |