Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
@files = File::Find::Rule->file ->name('complex.*') ->in ("/home"); $new = 'replace'; open (REPLACE, "<$new"); while (<REPLACE>) { push @new, $_ =~ m/^(\S+\s+\S+\s+\S+)/; } close (REPLACE); foreach $file (@files) { open (FH, "<$file"); open (OUT, ">output"); while (<FH>) { $_ =~ s/^\S+\s+\S+\s+\S+/$new[$i++] /; print OUT $_; $count++; rename "NEWNAMES", "NEWNAMES$count"; } close(FH); }
20040928 Edit by Steve_p: Changed title from 'File::Find'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing text in multiple files using File::Find
by si_lence (Deacon) on Sep 28, 2004 at 13:38 UTC | |
|
Re: Replacing text in multiple files using File::Find
by fjaenale (Acolyte) on Sep 28, 2004 at 14:44 UTC | |
|
Re: Replacing text in multiple files using File::Find
by Anonymous Monk on Sep 28, 2004 at 12:48 UTC |