R
Randy Kramer
On our local lug mail list a discussion came up about using Ruby (as opposed
to Perl) for an application that involved inserting a new line at the front
of an existing file.
(As a newbie), I proposed an approach like this (with help from the Ruby
Cookbook which I'm working my way through).
t = "New first line of file.\n"
t = t + open("sample_file") { |f| f.read }
open("sample_file", "w") { |f| f.write(t)}
However, it doesn't appear (to me) to be very Ruby-esque--I'm wondering how
others on this list might approach such a task.
Randy Kramer
to Perl) for an application that involved inserting a new line at the front
of an existing file.
(As a newbie), I proposed an approach like this (with help from the Ruby
Cookbook which I'm working my way through).
t = "New first line of file.\n"
t = t + open("sample_file") { |f| f.read }
open("sample_file", "w") { |f| f.write(t)}
However, it doesn't appear (to me) to be very Ruby-esque--I'm wondering how
others on this list might approach such a task.
Randy Kramer