使用lib时Perl发生错误

时间:2017-07-18 07:41:40

标签: perl batch-file perl-module

我有一个奇怪的问题,我called a CMD batch script, then the batch script called a perl script

C#启动过程

//
// Launch process.
//
string path = System.IO.Directory.GetCurrentDirectory();
ProcessStartInfo startInfo = new ProcessStartInfo()
{
    FileName = fileName,
    Arguments = arguments,
    WorkingDirectory = workingDirectory,
    UseShellExecute = false,
    RedirectStandardOutput = true,
    RedirectStandardError = true
};

Process process = Process.Start(startInfo);
process.BeginOutputReadLine();
process.BeginErrorReadLine();

批处理脚本:

"%PerlFolder%\perl.exe" "%CodeFolder%\test.pl"

test.pl

#!/usr/bin/perl

use strict;

#...
#code
foreach $key (keys(%ENV)) {
    printf("%-10.10s: $ENV{$key}\n", $key);
}

但是当使用lib时出现错误,我无法捕获错误,因为它在执行之前发生包含库(编译),似乎它没有找到lib,所以我用绝对路径替换它< / p>

use lib "C:/Program Files (x86)/perl/lib/strict.pm";

但它仍然不起作用,任何人都知道如何解决这个问题?

0 个答案:

没有答案