我在Perl中有一个疑问, 我需要在命令行参数/开关/选项中获取文件名,并基于此,我需要在脚本中包含/ require /使用该文件。 所以通过使用getopt变量可以完成它。但是,如果我在脚本中使用“严格使用”,我无法得到它。请对此Perl包含动态文件
我试过如下及其工作帮助
base.pm:
our $def_name = "me";
main.pl:
my $name = "mathlib.pm";
require $name;
print $def_name;
当我包括主要的follwoing线.pl和base.pm,
use strict;
use warnings;
我收到错误,
Global symbol "$def_name" requires explicit package name .
Execution of main.pl aborted due to compilation errors.
您是否认为'base.pm'和'mathlib.pm'有所不同? – Barmar
'mathlib.pm'怎么样? –
查看http://stackoverflow.com/questions/2648517/how-can-i-use-a-variable-as-a-module-name-in-perl – Himanshu