Rio-editing on-the-fly

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?

Wybo D. 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’)

Perhaps there’s a better suggestion?

Gavin

Wybo D. wrote:

Create a new Rio referencing the result of applying String#sub to the
value returned by Rio#to_s. So:

Now you’ve just gotta double check what Rio#to_s does :slight_smile:

Gavin

On Fri, 2 Dec 2005, Gavin S. wrote:

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))