From: gabriele renzi Date: 2003-09-17T19:34:36+09:00 Subject: Re: [newbie]saving and reading array of associative array il Wed, 17 Sep 2003 11:13:26 +0200, yvon.thoravallist@-SUPPRIMEZ-free.fr.invalid (Yvon Thoraval) ha scritto:: >i'm looking for examples of saving to file and reading back an array of >associative array, in a ruby like way. > >saying i have something like : > >one = {"Name" => "Smith", "Surname" => "John" ...} >two = {"Name" => "Dupont", "Surname" => "Jean" ...} > >myFriends = [one, two, ...] > >i want to save into a file "myFriends.db" the array of hashes myFriends >in such a way reading it back will recorver the array of hashes the >easiest way... ---------------------------------------------------------- Marshal::dump dump( anObject [, anIO] , limit=--1 ) -> anIO ------------------------------------------------------------------------ Serializes anObject and all descendent objects. If anIO is specified, the serialized data will be written to it, otherwise the data will be returned as a String. If limit is specified, the traversal of subobjects will be limited to that depth. If limit is negative, no checking of depth will be performed. More easy than you think ;) BTW you could even use PStore, included in the standard lib, it works similar to an hash, but gets saved on disk and supports 'transactions' for data integrity.