zuma53 has asked for the wisdom of the Perl Monks concerning the following question:

Hi--

If $x =
<foo> <bar>data</bar> <bar2>data2</bar2> <bar3>data3</bar3> </foo>
$x->sprint will print the above.
$x->text will print "datadata2data3".

Is there a way to print "data, data2, data3, "?

Thanks.

Replies are listed 'Best First'.
Re: XML-Twig: printing
by choroba (Cardinal) on Jun 26, 2012 at 22:34 UTC
    You can use a loop:
    print join ',', map $_->text, $x->children;
    (disguised as join and map).
      Ah! Why, of course.

      Thank you, sir!