codewalker has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I Just want process all xml files within multiple subfolders

But my current code is used to grep the files within the folder

use strict; undef $/; my $path = $ARGV[0]; my $out = $ARGV[1]; opendir(DIR, $path) || die "cannot read folder path"; my @xmlfiles = grep {/\.xml$/i} readdir(DIR); closedir(DIR); foreach my $xml(@xmlfiles) { open(FIN, "$path/$xml") or die("Couldn't open input File!!"); my $file = <FIN>;

Can anyone knows how to process within multiple folders in perl

Replies are listed 'Best First'.
Re: To process xml files within multiple subfolders in perl
by dasgar (Priest) on Nov 25, 2015 at 08:16 UTC

    I'd recommend checking out File::Find or File::Find::Rule to search for your XML files. Personally, I prefer File::Find::Rule. For what you're trying to do, the example code in the Synopsis of File::Find::Rule can be easily modified to look for *.xml instead of *.pm.

Re: To process xml files within multiple subfolders in perl
by Corion (Patriarch) on Nov 25, 2015 at 08:12 UTC