sub xml_output { my ($output, $tag, $fh) = @_; if($output) { if($output =~ m/(.*)/) { if($fh) { print $fh "\n"; close($fh); } open($fh, '>', "$1.xml") or die "$1.xml: $!"; print $fh "\n\n"; } $output =~ s/\s*(?=(<.+>|<.+\/>|<\/.+>|<\/.+><.+>))//g; print $fh "$output\n"; } return($fh); } # End of sub sroutine