in reply to Restoring a Data Structure from a File

Considering your specific example, I'd probably steer clear of XML. It's way over-kill for what you are looking for. There is no reason to not do something as simple as a text file where you put one address per line.
Joe@Host1.fqdn Schmoe@Host2.fqdn
and simply read the file in if it's there. It's super easy to edit in any given editor. And it's trivial to read in as well. You can loop through and build the array in what... 3 lines? And dumping it out is just as easy.
Don't over-engineer this. And yes, you are wise to not just blindly eval a document into the program. It sounds like a good app.
--
I used to drive a Heisenbergmobile, but everyone I looked at the speedometer, I got lost.

Replies are listed 'Best First'.
Re^2: Restoring a Data Structure from a File
by cmv (Chaplain) on Nov 02, 2007 at 14:59 UTC
    Kurt-

    You did good in pointing out the KISS solution here, as I failed to properly state the scope of the problem in my original request.

    Actually, this is how I started doing things, but ended up with data-feature-creep, as I kept adding bits of information about each usr@host. Things now look something like this:

    'me@hawaii' => { 'SSHinfo' => { 'Login' => 'myusr@warm.hawaii.com', 'socks_proxy' => 'mysocksproxy.com', 'socks_port' => 1234, 'socks_protocol' => 4, 'identity_files' => [ "$HOME/.sshspecial/toolauth" ], 'user_known_hosts' => "$HOME/.sshspecial/knownhosts", }, ... }, ...
    Having all this data tied to each entry, it'll be better for me to save the structure.

    -Craig

      I see what you mean by a structure now. At this point, you could consider XML, but I'd probably stick with something like CSV.
      As someone else mentioned, it's generally a good idea to store data format versioning in the file as well. If you go XML, it can be in a version= attribute. If you go CSV, make the first line have the col header information.
      --
      I used to drive a Heisenbergmobile, but everyone I looked at the speedometer, I got lost.