On 9/11/07, Gerald Wheeler <[EMAIL PROTECTED]> wrote: > I have about 400 text files I need to replace the contents. All files > are in the current directory as the perl script runs out of snip
What you need to do depends heavily on what you mean by "replace the contents". In general you can get away with something like perl -pi.bak -e 's/old stuff/new stuff/' * This will rename the existing files to whatever their name is plus ".bak" and then run the substitution against them storing the output in the original file names. The expanded script version of this is #!/usr/bin/perl use strict; use warnings; #set the inplace edit flag #this also has the effect of opening #and calling select on each file in @ARGV $^I = ".bak"; while (<>) { s/old stuff/new stuff/; print; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/