in reply to XML::LibXML creating nodes with a string OR a node
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML::LibXML creating nodes with a string OR a node
by worik (Sexton) on Jun 07, 2015 at 23:00 UTC | |
by Anonymous Monk on Jun 07, 2015 at 23:31 UTC | |
by worik (Sexton) on Jun 08, 2015 at 21:38 UTC | |
by Anonymous Monk on Jun 08, 2015 at 04:50 UTC | |
by worik (Sexton) on Jun 08, 2015 at 21:38 UTC | |
|
Re^2: XML::LibXML creating nodes with a string OR a node
by Anonymous Monk on Jun 07, 2015 at 22:48 UTC |