my @errors; my %valid = ( url => { required => 1, regex => qr{^http://[\w./]}, }, maxdepth => { required => 1, regex => qr{^\d+$}, maximum => 10, }, ); my $conf = MyConfig::General->new(\@conf); my %conf = $conf->getall; my %tmpl = %{$conf{template}}; for (keys %valid) { my $v = $valid{$_} or next; if ($v->{required}) { unless ($tmpl{$_} !~ /^\s*$/) { push @errors, "$_ is missing" } } if ($v->{regex}) { unless ($tmpl{$_} =~ /$v->{regex}/) { push @errors, "$_ has invalid format: $tmpl{$_}" } } if ($v->{maximum}) { unless ($tmpl{$_} <= $v->{maximum}) { push @errors, "$_ is too large: $tmpl{$_}" } } } print Dumper \@errors;