#!/usr/lib/perl use strict; use warnings; use Carp; use File::Find; use File::Spec::Functions qw( canonpath ); if ( @ARGV == 0 ) { push @ARGV, "C:/file/dir"; warn "Using default path $ARGV[0]\n Usage: $0 path ...\n"; } # open an output file whose name won't be found by File::Find open( my $allxml, '>', "all_xml_contents.combined" ) or die "can't open output xml file for writing: $!\n"; print $allxml '', "\n\n"; find( sub { return unless ( /[.]xml\z/i and -f ); extract_information(); return; }, @ARGV ); print $allxml "\n"; sub extract_information { my $path = $_; if ( open my $xmlin, '<', $path ) { local $_ = <$xmlin>; print $allxml $_ unless ( /<\?xml/ ); while ( <$xmlin> ) { print $allxml $_; } } return; }