Stephen Waits
3/26/2006 9:21:00 PM
On Mar 26, 2006, at 12:55 PM, Randy Kramer wrote:
> 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.
I think it's as good as anything. You could scrunch it up a bit like
this:
t = "New First Line\n" + File.read("sample_file")
...
--Steve