Hello Monks,
Using xml twig, I am trying to supply two elements in a line with the separator tab.
Ex: <c> <dl> ABC CDE add eerwe sdfsdfs erewrwe </dl> </c> Expected Result: <c> <dl> <first>ABC</first><second>CDE</second> <first>add</first><second>eerwe</second> <first>sdfsdfs</first><second>erewrwe</second> </dl> </c> Obtained Result: <c> <dl> <first>ABC</first><second>CDE</second> <first>add</first><second>eerwe</second> <first>sdfsdfs</first><second>erewrwe</second>rwe </dl> </c>

i.e. After </second> some characters are repeating, that character count is equivalent to line count. If i give five lines between
and
, then five characters are repeating.
Can any one tell where am i going wrong?
Code Used: my $t = new XML::Twig( twig_handlers => { "content"=>\&process_root }, pretty_print =>'nice', )->parsefile("$ARGV[0]"); my $say=$t->sprint; print FOUT "$say"; sub process_root { my ($a,$b,$c)=@_; my $bchild; for $bchild ($b->children) { if ($bchild->tag eq 'dl') { $bchild=&dl($a,$bchild); } } return $b; } sub dl { my ($a,$b,$c)=@_; my $bchild; if ($bchild->text) { $bchild->subs_text( qr{(.+?)\t(.+?)\n},'&elt(first=>{},$1)&elt(second=>{},$2)'); } return $b; }
Thanks in advance, -Anonymous user-

In reply to problem using XML Twig by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.