On 6/11/07, Li Chen <chen_li3 / yahoo.com> wrote:
> I just wonder what is the Ruby way to update a file in place. Do I need
> to open a temporary/new file for writing and then rename the temporary
> file?

There is also the '-i' argument to ruby. The example is from the man page:
================================
% echo matz > /tmp/junk
% cat /tmp/junk
matz
% ruby -p -i.bak -e "$_.upcase!" /tmp/junk
% cat /tmp/junk
MATZ
% cat /tmp/junk.bak
matz
================================

-- 
Luis Parravicini
http://ktulu.com.ar/blog/