in reply to One-shot code critique
use File::Find; { my @starters = @ARGV ? @ARGV : qw(/home/merlyn); @ARGV = (); find sub { push @ARGV, $File::Find::name if /\.asp$/; # or whatever condition + here }, @starters; } { local $/; # slurp it local $^I = ".bak"; while (<>) { # $_ now contains the entire file, alter at will s/foo/bar/g; print; } }
-- Randal L. Schwartz, Perl hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: My pattern for "in-place edit" for many files
by C-Keen (Monk) on Sep 29, 2001 at 13:56 UTC | |
by merlyn (Sage) on Sep 29, 2001 at 20:03 UTC | |
by C-Keen (Monk) on Sep 29, 2001 at 23:28 UTC | |
by Brovnik (Hermit) on Sep 30, 2001 at 02:44 UTC | |
Re: My pattern for "in-place edit" for many files
by tphyahoo (Vicar) on Aug 09, 2005 at 13:40 UTC | |
Re: My pattern for "in-place edit" for many files
by tphyahoo (Vicar) on Aug 09, 2005 at 14:40 UTC | |
Re: My pattern for "in-place edit" for many files
by tphyahoo (Vicar) on Aug 19, 2005 at 11:14 UTC |