Joe.Orcino has asked for the wisdom of the Perl Monks concerning the following question:
Having trouble with XML::Twig when used in a loop. Here is my code:
It seems to work fine except when sent a 2nd filename, the output suddenly goes to STDOUT instead of the $infile. Any ideas what is happening here, Mirod?sub twig { + # use twig to manipulate elements my $infile = shift ; my $processed = FALSE ; our $twigObject = XML::Twig->new ( twig_handlers => { 'TABLE' => \&get_tab, 'CTOC-ChapterTOC' => \&del_chaptoc, 'CTOC-ChapterTOCList' => \&del_chaptoc, 'STOC-SectionTitleTOC' => \&del_chaptoc, }, keep_atts_order => 1, keep_encoding => 1, pretty_print => "indented", ) ; my $logname = LOGD . "/conv_logfile.txt" ; open(LOG, ">> $logname" ) || die( "Can't open \'$logname\'.\nStopped " ); $twigObject->parsefile_inplace($infile, '.bak') || die( "WTF!! Something went wrong with the 'parse' " . "of \'$infile\'.\nStopped $!\n") ; $twigObject->flush() ; + # output back to original XML after Mods undef($twigObject) ; close(\*LOG) ; return(0) ; + # back to main }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: $twig->flush causing output to stdout?
by GotToBTru (Prior) on Mar 25, 2015 at 02:01 UTC | |
by Joe.Orcino (Initiate) on Mar 25, 2015 at 16:40 UTC | |
by soonix (Chancellor) on Mar 28, 2015 at 20:14 UTC | |
|
Re: $twig->flush causing output to stdout?
by Anonymous Monk on Mar 24, 2015 at 23:29 UTC |