How do I conditionally use a Perl module only if I'm on Windows?

后端 未结 4 751
醉话见心
醉话见心 2021-02-14 22:43

The following Perl code ..

if ($^O eq \"MSWin32\") {
  use Win32;                                                                                                         


        
4条回答
  •  盖世英雄少女心
    2021-02-14 23:21

    require Module;

    But use also calls import, require does not. So, if the module exports to the default namespace, you should also call

    import Module qw(stuff_to_import);

    You can also eval "use Module" - which works great IF perl can find the proper path at runtime.

提交回复
热议问题