在Windows上运行perl脚本(Running a perl script on Windows)

我有一个在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";

I have a script that run in Ubuntu but, I would like to run it in windows. I know how to execute it I just don't know what is wrong with my script to not make it run.

#!/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";

最满意答案

试试这个:

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

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

显式调用glob比< >更好,而使用/而不是\简化了引用。

Try this instead:

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

and

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

Calling glob explicitly is better than < >, and using / instead of \ simplifies quoting.

在Windows上运行perl脚本(Running a perl script on Windows)

我有一个在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";

I have a script that run in Ubuntu but, I would like to run it in windows. I know how to execute it I just don't know what is wrong with my script to not make it run.

#!/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";

最满意答案

试试这个:

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

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

显式调用glob比< >更好,而使用/而不是\简化了引用。

Try this instead:

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

and

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

Calling glob explicitly is better than < >, and using / instead of \ simplifies quoting.