use warnings; use strict; use Config::IniHash; # parse the config file into a hashref my $config = ReadINI 'pm1562.ini'; # default values my $defaults = { header => { to => 'foo', from => 'bar' } }; # iterate the defaults and put them into $config if they not # already exist for my $section ( keys %{$defaults} ) { for my $option ( keys %{$defaults->{$section}} ) { $config->{$section}->{$option} = $defaults->{$section}->{$option} unless exists $config->{$section}->{$option}; } } #use the values, no need for a variable $to or $from print $config->{header}->{to}, "\n", $config->{header}->{from}, "\n",