in reply to How to Modify Each file??

Instead of copying the files, open each source file for reading, open the destination file for writing, read in a line, modify the line (with a regex or split, then print the modified version to the destination filehandle.

Replies are listed 'Best First'.
Re^2: How to Modify Each file??
by Anonymous Monk on Oct 20, 2007 at 21:19 UTC
    can you please help me out with code in reading writing into output
      something very rough with some details left out
      opendir THISDIR, 'whatever/thisdir'; my @files = readdir(THISDIR); foreach my $x (@FILES){ open READFILE, "whatever/thisdir/$x"; open WRITEFILE, ">whatever/thatdir/$x"; while(<READFILE>){ chomp; my @parts = split(/\s/, $_); print WRITEFILE $parts[1], " ", $parts[0], "\n"; } close WRITEFILE; close READFILE; }
A reply falls below the community's threshold of quality. You may see it by logging in.