【问题标题】:Running a perl script on Windows在 Windows 上运行 perl 脚本
【发布时间】:2018-03-31 15:23:31
【问题描述】:

我有一个在 Ubuntu 中运行的脚本,但是我想在 Windows 中运行它。我知道如何执行它我只是不知道我的脚本有什么问题不能让它运行。

#!/usr/bin/perl

use strict;
use warnings;
use IO::Compress::Zip qw(zip $ZipError);
use File::Find;

my @files = <C:\Windows\*.log>;

zip [ @files ] => 'Desktop/output.zip'
    or die "zip failed: $ZipError\n";

unlink glob "'C:\Windows\*.log'";
print "The job is done\n";

【问题讨论】:

  • 我会说glob之后的字符串。为什么不重用与@files 相同的语法?可能还有 &lt;C:\...&gt; 部分中的反斜杠。我无法在 Windows 上进行测试。
  • Perl 会抛出什么错误?

标签: windows perl


【解决方案1】:

试试这个:

my @files = glob 'C:/Windows/*.log';

unlink glob 'C:/Windows/*.log';

显式调用glob 优于&lt; &gt;,使用/ 代替\ 可以简化引用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多