my $filename="Taps/Output.xml"; my $fh; open($fh, '>:encoding(UTF-8)', $filename) or die "file, $!"; foreach my $file(glob 'Taps/DA*') { my $tap3 = TAP3::Tap3edit->new(); $files= basename($file); #<< are you sure this is needed/does it work? $tap3->decode($files) || die $tap3->error; print $fh $dump->pl2xml($tap3->structure); } close $fh;