How do I use a Perl package known only in runtime?

后端 未结 7 540
忘掉有多难
忘掉有多难 2020-12-10 02:21

I have a Perl program, that needs to use packages (that I also write). Some of those packages are only chosen in Runtime (based on some environment variable). I don\'t want

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 03:17

    "use" Statements are run at compilation time, not at run time. You will need to require your modules instead:

    my $module = "Foo::Bar";
    eval "require $module";
    

提交回复
热议问题