in reply to perl -i
Although that could be reduced to a one-liner, if you wanted: perl -pi -e 's/bar/foo/g' myfile#!perl -i # or: # $^I = ''; @ARGV = ('myfile'); while (<>) { s/foo/bar/; print; }
By the way, note that these two code snippets have the same result, but one is cleaner:
if (/foo/) { s/foo/bar/g; } s/foo/bar/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: perl -i
by malloc (Pilgrim) on May 24, 2001 at 22:57 UTC |