Hello all,
I wrote a script to condense a very large XML file with XML::Twig on ActivePerl 5.6.1 - worked great! I upgraded to ActivePerl 5.8.8 and it broke with
"Can't call method "flush" on an undefined value at C:/Perl/site/lib/X +ML/Twig.pm line 6832, <INFILE> line 4083."
Here is the offending section, it breaks with the first flush():
select \*OUTFILE; my $t = new XML::Twig( twig_roots => { # 'MemberID' => \&member, 'Aging' => \&balance, 'Transaction' => \&transaction +, 'Line' => \&line, 'Chits' => \&chits}, pretty_print => 'indented', twig_print_outside_roots => \*OUTFILE, + # print the rest ); $t -> parsefile ("temp.xml"); <snip> sub balance { my ($t, $balance) = @_ ; my %balance; $balance{30} = $balance->field( 'BAL_30' ); $balance{60} = $balance->field( 'BAL_60' ); $balance{90} = $balance->field( 'BAL_90' ); $balance{120} = $balance->field( 'BAL_120' ); $balance{150} = $balance->field( 'BAL_150' ); $balance{180} = $balance->field( 'BAL_180' ); local ($balance90, $balance120, $balance150, $balance180); $balance30 = $balance{30}; $balance60 = $balance{60}; $balance90 = $balance{90}; $balance120 = $balance{120}; $balance150 = $balance{150}; $balance180 = $balance{180}; local $balancelate = ($balance90 + $balance120 + $balance150 + $ba +lance180); $balancelate =$rounder->round($balancelate); $balance->delete(90); $balance->delete(120); $balance->delete(150); $balance->delete(180); my $balance30elt = new XML::Twig::Elt('BAL_30', $balance30); $balance30elt->set_text($balance30); $balance30elt->set_att(Period => 1); $balance30elt->paste('first_child', $balance); my $balance60elt = new XML::Twig::Elt('BAL_60', $balance60); $balance60elt->set_text($balance60); $balance60elt->set_att(Period => 2); $balance60elt->paste('last_child', $balance); my $balance90 = new XML::Twig::Elt('BAL_90', "$balancelate"); $balance90->set_text( "$balancelate" ); $balance90->set_att(Period => 3); $balance90->paste('last_child', $balance); $balance -> flush(\*OUTFILE); }
I want to use WxPerl to put a nice Windows wrapper around it, so I need the 5.8.x. Any help or insight would be greatly appreciated! -Mike

Edited by planetscape - removed pre tags, replaced with code tags


In reply to XML-Twig - AS5.6.1 vs AS 5.8.8 by drmikec

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.