in reply to How to use variables in @INC and "use" commands
use doesn't work that way. use always wants a bareword and not a variable as the module name. To dynamically load a module, use require:
... my $module_file = "$tmp.pm"; require $module_file; $module_file->import(qw(%diary));
Then you can even ditch the @INC hackery:
... my $module_file = "dir_$day/$userId.pm"; require $module_file; $module_file->import(qw(%diary));
|
|---|