I was surprised to find out that this does not work:
whoranit = sub { $ENV{USERNAME} || $ENV{USER} }
log4perl.appender.x.ConversionPattern = %d ${whoranit} %m%n
the sub isn't run when the variable $whoranit is defined, it stays just
a string.
It has to do with the order things happen in the ConfigParser:
# Everything could potentially be a variable assignment
$var_subst{$key} = $val;
# Substitute any variables
$val =~ s/\${(.*?)}/
Log::Log4perl::Config::var_subst($1, \%var_subst)/gex;
$val = eval_if_perl($val) if
$key !~ /\.(cspec\.)|warp_message|filter/;
We could change this by putting the assignment at the end after the
eval_if_perl() instead of the beginning, then you could do stuff like
variable interpolation inside variables, and variable interpolation
inside perlcode, none of which you can do now
name=bob
fullname=${name} smith
greeting=sub{'hi there '.${fullname}}
but it could concievably break current configurations, so maybe it's a
can of worms we don't want to open.
Any comments?
--
Happy Trails . . .
Kevin M. Goess
(and Anne and Frank)
904 Carmel Ave.
Albany, CA 94706
(510) 525-5217
|