in reply to perlpie only on files with affected contents
#!/usr/bin/perl $^I = ".bak"; @ARGV = glob "*"; while (<>) { s/old/new/ and $changes = 1; print; if (eof) { # retreat if no changes: rename "$ARGV$^I", $ARGV unless $changes; $changes = 0; # reset } }
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: perlpie only on files with affected contents
by stabu (Scribe) on Apr 29, 2004 at 16:48 UTC |