in reply to eval question

You may find it helpful to use something like YAML to load and save configuration information. It's not an immediate complete solution to your multiple entry problem, but consider the following:

use strict; use warnings; use YAML; use Data::Dump; my %configHash = ( cat => 'Fred', dog => 'Joe', ); my $cfgFileContents = YAML::Dump(\%configHash); Data::Dump::dump (\%configHash); print $cfgFileContents; $cfgFileContents .= "cat: Bob\n"; # User added configuration entry my $loaded = YAML::Load($cfgFileContents); Data::Dump::dump ($loaded); $cfgFileContents = <<DATA; --- cat: - Fred - Bob dog: Joe DATA $loaded = YAML::Load($cfgFileContents); Data::Dump::dump ($loaded);

Prints:

{ cat => "Fred", dog => "Joe" } --- cat: Fred dog: Joe { cat => "Fred", dog => "Joe" } { cat => ["Fred", "Bob"], dog => "Joe" }

Note that the "User added configuration entry" gets lost (YAML specifies that there must be only one entry for each key in a hash and that additional entries will be ignored). However multiple values can be specified for a hash key if they are entries in a nested list, hence the nested array in the last line.

True laziness is hard work