As a quick remedy until someone who knows better can help you, try opening the output file before the loop, and then APPEND the structure to the file inside the loop. I believe from a quick glance at XML::Dumper that pl2xml($perl, $filename) does not append but overwrites whatever the current contents of file with $perl. If you omit the $filename, you will get the xml string back, e.g. my $xmlstr = pl2xml($perl); (untested). So, open the output file before the loop: open($fh, '>:encoding(UTF-8)', $filename) or die "file, $!"; Then inside the loop, after decode(): $perl = $tap3->structure; my $xmlstr = $dump->pl2xml($perl); print $fh $xmlstr; OR simpler: print $fh $dump->pl2xml($tap3->structure); And after the loop close $fh; But perhaps you want a new $tap3 object to be created inside the loop each iteration?
In reply to Re: Run a perl code on all input files and have the results in different output files
by bliako
in thread Run a perl code on all input files and have the results in different output files
by SaraMirabi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |