in reply to flavors of "defined"
Seriously, don't.
Use a global hash of values instead, if you're going to do that at all. You still don't need to create separate little subroutines, though if you did, it wouldn't really be that bad.
Really, is that so bad?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"; } }
|
|---|