In this example an array is written to file using Marshal.dump and read from file using Marshal.load.

- Writing the object to file -

File.open('entries', 'w+') do |f|
Marshal.dump(entries, f)
end
#=> #


- Recreating the object from file -

entries = []
File.open('entries') do |f|
entries = Marshal.load(f)
end

puts entries[-1][:title]
=> "Parsing snippets.dzone.com posts"


Resources:
- Serializing objects in Ruby [dzone.com]
- Module: Marshal [ruby-doc.org]

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/Y4PBI1Iy-3M/11741