in reply to Re^2: Reading from a flat text file database and storing contents in a hash
in thread Reading from a flat text file database and storing contents in a hash

If the number of entries (for whatever definition of entry) is modest then using Data::Dump::Streamer is likely to be as good as anything. If you anticipate a large number of entries then it's probably worth finding out about DBI and the various DBD drivers that allow you to use a "real" data base.

However, for the simple case consider:

use strict; use warnings; use Data::Dump::Streamer; my %services = ( 1 => { name => "service1", host => { host1 => 1 }, }, 2 => { name => "service2", host => { host0 => 2, host5 => 2 }, }, ); Dump (\%services); open TEMP, '>', 'temp.txt'; print TEMP Dump (\%services)->Out (); close TEMP; my $newServices = do 'temp.txt'; Dump ($newServices);

Prints:

$HASH1 = { 1 => { host => { host1 => 1 }, name => 'service1' }, 2 => { host => { host0 => 2, host5 => 2 }, name => 'service2' } }; $HASH1 = { 1 => { host => { host1 => 1 }, name => 'service1' }, 2 => { host => { host0 => 2, host5 => 2 }, name => 'service2' } };

DWIM is Perl's answer to Gödel