donglv6960 2013-04-30 21:00
浏览 134
已采纳

当php执行脚本时找不到Perl模块

I execute a perl script with exec via php, however I receive an error that the module Net::DNS is missing. I have installed the module as a regular user and as such is located in /home/user/perl5/i686-linux-thread-multi and I do use a full path (/usr/bin/perl) in the exec.

I've even tried to add the /home/user/perl5/i686-linux-thread-multi directory to @INC but the script still throws the error...

And I also tried to install the module with custom install path directly into /usr/lib/perl5/vendor_perl, but that didn't solve the problem either. And symlink didn't fix that either.

Here is the error message

  Can't locate Net/DNS.pm in @INC (@INC contains: 
/usr/lib/perl5/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/vendor_perl 
/usr/share/perl5/vendor_perl /usr/lib/perl5/core_perl /usr/share/perl5/core_perl

Any idea how this can be solved, sort of running out of ideas how to deal with this.

  • 写回答

2条回答 默认 最新

  • doubutao6216 2013-04-30 21:16
    关注

    before exec, add:

    $ENV{PERL5LIB} = "$ENV{PERL5LIB}:/home/user/perl5/i686-linux-thread-multi";
    

    Why using use lib wont work (for pavel's comment):

    #!/usr/bin/env perl
    use strict;
    use warnings;
    use lib "hate_you";
    use Data::Dumper;
    
    print Dumper(\@INC);
    
    print "In sub process....
    ";
    exec(qq{perl -MData::Dumper -e "print Dumper(\@INC);"});
    

    will print on my machine:

    $VAR1 = [
              'hate_you',
              '/etc/perl',
              '/usr/local/lib/perl/5.14.2',
              '/usr/local/share/perl/5.14.2',
              '/usr/lib/perl5',
              '/usr/share/perl5',
              '/usr/lib/perl/5.14',
              '/usr/share/perl/5.14',
              '/usr/local/lib/site_perl',
              '.'
            ];
    In sub process....
    
        $VAR1 = '/etc/perl';
        $VAR2 = '/usr/local/lib/perl/5.14.2';
        $VAR3 = '/usr/local/share/perl/5.14.2';
        $VAR4 = '/usr/lib/perl5';
        $VAR5 = '/usr/share/perl5';
        $VAR6 = '/usr/lib/perl/5.14';
        $VAR7 = '/usr/share/perl/5.14';
        $VAR8 = '/usr/local/lib/site_perl';
        $VAR9 = '.';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器