首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法打开文件perl

无法打开文件perl
EN

Stack Overflow用户
提问于 2012-10-29 04:42:56
回答 1查看 730关注 0票数 1

我正在尝试将plist文件转换为JUnit样式的XML。我有一个xsl样式表,它将plist转换为JUnit/ANT。

下面是我运行的perl代码,用于将plist转换为XML:

代码语言:javascript
复制
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
my $stylesheet = $xslt->parse_stylesheet_file("\\\~/Hudson/build/workspace/ui-automation/automation\\\ test\\\ suite/plist2junit.xsl");

my $counter = 1;
my @plistFiles = glob('Logs/*/*.plist');
foreach (@plistFiles){
    #Escape the file path and specify abosulte path
    my $plistFile = $_;
    $plistFile =~ s/([ ()])/\\$1/g;
    $path2plist = "\\\~/Hudson/build/workspace/ui-automation/automation\\\ test\\\ suite/$plistFile";
    #transform the plist file to xml
    my $source = $parser->parse_file($path2plist);
    my $results = $stylesheet->transform($source);

    my $resultsFile = "\\\~/Hudson/build/workspace/ui-automation/automation\\\ test\\\ suite/JUnit/results$counter.xml";
    #create the output file
    unless(open FILE, '>'.$resultsFile) {
    # Die with error message
    die "\nUnable to create $file\n";
    }

    # Write results to the file.
    $stylesheet->output_file($results, FILE);
    close FILE;
    $counter++;
}

在Hudson/Jenkins上运行perl脚本后,它将输出以下错误消息:

无法打开~/Hudson/build/workspace/ui-automation/automation\测试\套件/日志/Run\1/自动化\ Results.plist:没有这样的文件或目录

错误是由代码中的my $source = $parser->parse_file($path2plist);引起的。我不明白为什么它找不到/读不到这个文件。

有人知道是什么导致了这个错误吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-29 05:06:40

在错误消息中提到的路径中有三个明显的错误。

代码语言:javascript
复制
~/Hudson/build/workspace/ui-automation/automation\ test\ suite/Logs/Run\ 1/Automation\ Results.plist

这些措施是:

  1. 当前目录中没有名为~的目录。也许您打算在那里使用$ENV{HOME}的值?
  2. 磁盘上任何地方都没有名为automation\ test\ suite的目录,但可能有一个名为automation test suite的目录。
  3. 类似地,磁盘上任何地方都没有名为Run\ 1的目录,但可能有一个名为Run 1的目录。
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13115952

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档