Chetak Sasalu wrote:
>
> I have to search and replace 'foo' to 'bar' in all the files in a
> directory(has subdirectories).
> The files are about 40k in size.
>
> On the command line I would do it as,
> find ./mydir/ -type f -print | xargs perl -pi -e 's/foo/bar/'
>
> No backup of the original files required.I am brave.
>
> What is the most efficient way to implement this inside a perl program ?
> There are about 30 files to be processed.
> I went through perldoc perlrun and saw the code.
use strict;
use warnings;
local @ARGV = grep -f, <./mydir/*>;
$^I = '';
while (<>) {
s/foo/bar/g;
print;
}
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>