## Globbing opendir(DIR, $inPath) or die$!; my @xmlfiles = glob("*.xml"); foreach my $file (@files) { print "$file\n"; ## Lists all the files } #### for(my $file =0; $file<=$#xmlfiles; $file++){ ## $#xmlfiles gives you the last index of the file or length of the array -1 open my $IN, $file or die $!; open my $OUT, ">outfile.txt" or die $!; while(<$IN>){ ## read the file line by line ## split and parse the words you are interested in ## suppose $word has the word u want to output in the file then, $word is a scalar variable print $OUT $word,"\n"; } close($IN); } close($OUT);