my %globals = map { $_ => undef } qw/ all allowed names here including DoDebug /; sub dynConf { my ($name, $val) = @_; if (exists $globals{$name}) { $globals{$name} = $val; } else { die "Huh? No such variable: $name"; } } # create the get-functions for (keys %globals) { # probably could do this without eval STR, but let's keep it simple eval "sub get_$_ { $globals{'$_'} }"; } # or just one get-function sub get_global { my $name = shift; if (exists $globals{$name}) { $globals{$name} } else { die "No such global: $name"; } }