From: Wybo Dekker Date: 2005-12-02T17:44:04+09:00 Subject: Re: rio-editing on-the-fly On Fri, 2 Dec 2005, Gavin Sinclair wrote: > > Wybo Dekker wrote: > > according to the rio-docs I would expect it to be possible to edit a file > > on-the-fly; for example, I tried to make a copy of /etc/passwd with my own > > name (wybo) replaced with XXXX: > > > > rio('/etc/passwd').gsub(/wybo/,'XXXX') > rio('new') > > > > but the resulting file "new" is an exact copy of /etc/passwd. > > What am I doing wrong? > > You're not reading the file. Try > > rio('/etc/passwd').read.gsub(/wybo/,'XXXX') > rio('new') that helped indeed, thanks, but is it not in contradiction to rio's description of sub?: sub(re,string) Create a new Rio referencing the result of applying String#sub to the value returned by Rio#to_s. So: ario.sub(re,string) is equivelent to rio(ario.to_s.sub(re,string)) -- Wybo