【问题标题】:Can clear case perl - ccperl handle with a path contains spaces?可以清除大小写 perl - ccperl 句柄与路径包含空格吗?
【发布时间】:2012-09-27 16:05:12
【问题描述】:

我正在尝试打开一个路径包含空格的文件,比如:

open(FILE, "some\\path with spaces")

我在 Windows 上使用ccperl,我收到错误“无法打开文件”

我已经尝试过q!"..."! 尝试过"\path\ with\ spaces" 等等...

有什么想法吗?

【问题讨论】:

    标签: perl clearcase


    【解决方案1】:

    让我们看看。在我的 ActivePerl 5.14.2 上,我可以执行以下操作:

    #!C:\perl\bin\perl.exe
    use strict; use warnings;
    open my $fh, '<', 'C:\Dokumente und Einstellungen\user\Desktop\file spaces.txt'
      or die $!;
    print while <$fh>;
    close $fh;
    

    与您所做的不同之处在于我使用了单引号'。在它们内部,反斜杠\ 不被视为元字符,因此无需转义它。您也不需要转义空格。你应该试试看。


    顺便说一句,您是否使用strictwarnings?他们可能会告诉你哪里出了问题,我的or die $! 可能会。

    我还建议您使用openlexical filehandles 中的three argument form

    【讨论】:

      【解决方案2】:

      来自this matrix,ccperl 通常表示带有 ClearCase 的 perl 5.8.6。

      ccperl scripts examples 建议:"\"your file path\"",但这可能与 open 不兼容。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-26
        • 1970-01-01
        相关资源
        最近更新 更多