My output from my test script looks like this:print STDERR "FUNCTION IS ($func)\n"; print STDERR "(\&is_int) TRUE!\n" if &is_int(42, 1); print STDERR "(is_int) TRUE!\n" if is_int(42, 1); print STDERR "(Module::Configurable::is_int) TRUE!\n" if Module::Configurable::is_int(42, 1); no strict 'refs'; print STDERR "(\&\$func) TRUE!\n" # line 137 from output +below if &$func(42, 1); # line that's dieing
As you can see from the debug output, the first three versions of my attempt to use the is_int function are working fine. The function is_int is imported into my namespace (evident since is_int works by itself) and can be called successfully from the longer Module::Configurable::is_int form as well. However, when I try to access it with the name stored into the $func scalar, it doesn't seem to know what it is any more.FUNCTION IS (is_int) (&is_int) TRUE! (is_int) TRUE! (Module::Configurable::is_int) TRUE! not ok 3 - Configure is successful with valid data # Failed test 'Configure is successful with valid data' # at t/Module-Configurable.t line 49. # died: Undefined subroutine &Module::Configurable::is_int called at / +nfs/pdx/disks/nehalem.pde.077/projects/libraries/Module/blib/lib/Modu +le/Configurable.pm line 137.
The function name seems correct, and it's checking the correct package namespace for the function. I've been trying many variations to pinpoint what's going on here, but I'm not having much luck and would appreciate an experienced eye :) I can make it work, but I'd like to know what I'm doing wrong as opposed to working around something I don't understand.
Update:
This works by specifying the full module name of the function in use...but why does it not work the other way?print STDERR "(\&{\$func}) TRUE!\n" if &{'Params::SimpleValidate::'.$func}(42, 1);
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |