('additional_test_module::'.$var1)->(object_vars($var1));
But I think you don't want to.
There are some problems with the approach:
- It doesn't work under 'strict' (and you are using strict, aren't you?)
- It can blow up in your face if the variable contains something strange (like, spaces...)
- It's ugly ;-)
A better approach is:
our %subs=('value X'=>\&module::subX,
'value Y'=>\&module::subY,
'somethingelse' => \&module::else);
$var=get_the_var();
if (test($var)) {
if (exists $subs{$var}) {
$subs{$var}->(object_vars($var))
} else {
signal_error($var)
}
}
This stores all known subs in a hash, then calls the right one.
Oh, I'm assuming that when you say "don't know the variable name" you mean the "value".
If you really don't know the possible values of the var, or the possible subs to call, then you have other problems than to worry about 'strict', so you can go with my first code, and in the meantime re-design the system ;-)))
--
dakkar - Mobilis in mobile
|