[Pdx-pm] filewise (not linewise) in-place editing?
Michael G Schwern
schwern at pobox.com
Wed Oct 20 19:13:17 CDT 2004
On Wed, Oct 20, 2004 at 04:22:39PM -0700, Randall Hansen wrote:
> i've just needed to munge a group of files to change and concatenate
> data on several lines into one line. usually i do something like:
>
> perl -pi -e 's/foo/bar/g' file1 ...
>
> this wouldn't work, since -p reads input files linewise.
>
> i wrote a little script to solve my problem, it resets $/ and sucks the
> whole file into a variable, munges it, and writes it. is there a way
> to do this in a one-liner, similar to the above*?
perl -0777 -pi -e 's/foo/bar/g' file1 ...
--
Michael G Schwern schwern at pobox.com http://www.pobox.com/~schwern/
It's Tobacco time!
More information about the Pdx-pm-list
mailing list