|
Defaults are specified in 3 places: The :InitArgs hash, the
:Args attribute and the :Default attribute. They all need
to work consistent with each other. Because :InitArgs are
'compiled', they can not be 'eval'ed at assignment time.
my %init_args :InitArgs = (
'cref' => {
'field' => \@cref,
'default' => sub { return 'foo' },
},
);
In the above, because the default is a code ref, you cannot
do a string eval on it.
Additionally, defaults are currently 'static' data.
Implementing some sort of eval mechanism to get dynamic
defaults would cause incompatibilities.
Therefore, you'll need to contend with preprocessing to do
what you want. That's one of the reasons it was provided. |