in reply to Config file default options?
Given a config file likeuse 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}->{$opti +on} 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",
this prints[header] to=holli
Just as i think you need it.holli bar
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Config file default options?
by jonadab (Parson) on Sep 07, 2006 at 11:46 UTC |