簡體   English   中英

你如何使用 7z 測試?

[英]How do you use the 7z test?

文件的目錄已定義。

我想使用 7z 的“測試”命令獲取“測試”值。

foreach $str0 (glob "*.zip"){
    my $test = system( "7z t -y $str0");
    print $test;
}

如何獲得“7z 測試”值?


編輯:

你的意思是使用 qx 而不是系統?

你是這個意思對嗎?

foreach $str0 (glob "*.zip"){
    my $test = qx/7z t -y $str0/;
    print $test;
}

或者

foreach $str0 (glob "*.zip"){
    my $test = `7z t -y $str0`;
    print $test;
}

我都試過了,但我無法獲得“測試值”。

Perl至少有3種方法; qx和反引號的方式基本上是一樣的,除了qx你可以選擇使用什么分隔符來開始/結束字符串。 使用'作為分隔符可防止變量插值。

第三種方式是用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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM