[英]How do you use the 7z test?
The directory of the file is defined.文件的目录已定义。
I want to get the 'test' value using the 'test' command of 7z.我想使用 7z 的“测试”命令获取“测试”值。
foreach $str0 (glob "*.zip"){
my $test = system( "7z t -y $str0");
print $test;
}
How can I get the '7z test' value?如何获得“7z 测试”值?
Edit:编辑:
Do you mean to use qx instead of System?你的意思是使用 qx 而不是系统?
Is it right that you meant it?你是这个意思对吗?
foreach $str0 (glob "*.zip"){
my $test = qx/7z t -y $str0/;
print $test;
}
or或者
foreach $str0 (glob "*.zip"){
my $test = `7z t -y $str0`;
print $test;
}
I tried both, but I can't get the 'test value'.我都试过了,但我无法获得“测试值”。
There are at least three ways to do this in Perl; Perl至少有3种方法; the qx
and backticks ways are basically the same thing, except with qx
you have a choice of what delimiter to use to start/end the string. qx
和反引号的方式基本上是一样的,除了qx
你可以选择使用什么分隔符来开始/结束字符串。 Using '
as the delimiter prevents variable interpolation.使用'
作为分隔符可防止变量插值。
The third way is using open
to open a pipe to 7zip.第三种方式是用open
打开一个pipe到7zip。
#with qx
my $test = qx/7z t -y $str0/;
#with backticks
my $test = `7z t -y $str0`;
#with open
open my $pipe, '-|', '7z', 't', '-y', $str0;
my $test = join "\n", readline $pipe;
close $pipe;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.