http://www.perlmonks.org?node_id=1007919


in reply to Recursive file processing from a path and printing output in a file

Examine File::Find::Rule and more specifically the start and match methods.

The logic of your program can then be simplified as follows:

use Modern::Perl; use File::Find::Rule; my $start_dir = 'c:/Test'; my $rule = File::Find::Rule->file->start($start_dir); while ( defined( my $file = $rule->match ) ) { # process $file ... }
Why do you need to replace the spaces in the files you found to comma's? I cannot see any good reason for that.

To transform your files into XML format, several XML modules exist, such as XML::Writer. Writing XML is not simple, there are many rules to follow and these modules take care of it.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics