in reply to parsing files and modifying format

perhaps you could work with something from the command line like

for i in `find . *.txt`; do perl -pi -e 's/\n/,/' $i; done;

update or maybe a Perl only solution. This one uses recursion to traverse subdirs.

#!/usr/bin/perl use strict; use warnings; my $dir = "."; lista_dirs($dir, $dir); sub lista_dirs { my ($dir, $dirname) = @_; my (@dirs, @files); opendir DIR, "$dir"; my @dircontent = grep { /[^\.]/ } readdir(DIR); closedir DIR; @dirs = (); @files = (); foreach(@dircontent) { if(-d "$dir/".$_) { push @dirs, $_; } else { push @files, $_ if($_ =~ /\.txt$/); } } foreach my $d(@dirs) { lista_dirs("$dir/".$d, $d); } # IMPORTANT NOTE: if your files aren't too big, you can read every +thing at once as shown in the code below. # if note, you can open +the input file for reading and a temp file for wirting. Read the file + line by line, # replace \n with the , and write to the temp file +. Close both files when you're done, and then 'rename' # the temp file to the input filename foreach my $file (@files) { $/ = ''; open FILE, "$dir/$file"; my $content = <FILE>; close FILE; $content =~ tr/\n/,/; open FILE, ">$dir/$file"; print FILE $content; close FILE; } return; } <p><b>update 2</b> After reading the other replies I realized I misrea +d the question, and there was no need for recursion, so the solution +came to be more complex than it needed to be. I was really in the nee +d to get some sleep.</p>