所以,我有一个这样的程序:
#!/usr/bin/perl -w
use strict;
foreach (@data) {
if($_ eq "foo") {
use Foo;
process();
}
if($_ eq "bar") {
use Bar;
process();
}
...
}
Run Code Online (Sandbox Code Playgroud)
每个包含的模块有点类似,唯一的区别是process() - sub的作用.
#!/usr/bin/perl -w
use strict;
sub process {
...
}
Run Code Online (Sandbox Code Playgroud)
我的问题:主脚本的输入是一个(可能很长)的事情列表,而处理该列表我得到连续的"子程序重新定义"错误(显然).有没有办法"取消使用"模块?
由于包含的可能"行动"库可能会在未来增长,我认为这种动态包含模块的方式将是最好的方法.非常感谢您的帮助 :)