Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

To process xml files within multiple subfolders in perl

by codewalker (Acolyte)
on Nov 25, 2015 at 04:04 UTC ( [id://1148572]=perlquestion: print w/replies, xml ) Need Help??

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1148572]
Approved by philipbailey
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-26 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found