如何在 Windows 上用 Perl 调用 winrar?

发布于 2024-08-27 22:00:49 字数 310 浏览 4 评论 0原文

是否可以在Windows系统上通过perl调用winrar,例如

perl -e "rar a -rr10 -s c:\backups\backup.rar @backup.lst"

如果可以,是否有更有效的方法来做到这一点?

我在谷歌上查找了“perl -e”+winrar,但是没有一个结果给了我任何与我正在寻找的答案相距甚远的答案。我运行的系统是Windows XP系统。如果更容易的话,我愿意用另一种语言(例如 python)来完成此操作;不过我对 Perl 更满意。

Is it possible to call winrar through perl on a windows system, such as

perl -e "rar a -rr10 -s c:\backups\backup.rar @backup.lst"

If so, is there a more efficient way to do this?

I've looked up "perl -e" +winrar on google, however none of the results gave me any answer that was remotely close to what I was looking for. The system I'm running this on is a Windows XP system. I'm open to doing this in another language like python if its easier; however I am more comfortable with Perl.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

许你一世情深 2024-09-03 22:00:49

您可以使用 CPAN 模块 Archive::Rar 访问 Windows 中的 RAR 工具:

use Archive::Rar;
my $rar = Archive::Rar->new(-archive => $archive_filename);
$rar->Extract();

You can access the RAR facilities in Windows using the CPAN module Archive::Rar:

use Archive::Rar;
my $rar = Archive::Rar->new(-archive => $archive_filename);
$rar->Extract();
摇划花蜜的午后 2024-09-03 22:00:49

从 Perl 脚本执行外部命令的一种方法是使用 system

my $cmd = 'rar a -rr10 -s c:\backups\backup.rar @backup.lst';
if (system $cmd) {
    print "Error: $? for command $cmd"
}

One way to execute external commands from a Perl script is to use system:

my $cmd = 'rar a -rr10 -s c:\backups\backup.rar @backup.lst';
if (system $cmd) {
    print "Error: $? for command $cmd"
}
任谁 2024-09-03 22:00:49

要使用 Perl 程序中的外部应用程序,请使用 system 内置程序。

如果需要命令的输出,可以使用反引号 (``) 或 qx 运算符,如 perlop。您还可以使用 perlipc

To use external applications from your Perl program, use the system builtin.

If you need the output from the command, you can use the backtick (``) or qx operator as discussed in perlop. You can also use pipes as discussed in perlipc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文