我的要求如下:讀WMIC命令的輸出到一個單一的陣列,並且處理所述陣列在Perl
我正在讀的WMIC命令的輸出如下所示:
my @pnames = `wmic product where "Name like '%Provider%'" get IdentifyingNumber, Name,Version`;
print "@pnames";
直到這裏的輸出如下:
IdentifyingNumber Name Version
{E094B8EA-87B7-48DE-A0A8-A18AC8BFCDF4} .NET Data Provider for Teradata 14.00.0.0 14.00.0.0
{1551F9D6-1B14-4AE1-BABA-70A4319C236A} ODBC Driver Provider 14.00.0.0
Proceesing陣列
foreach $name (@pnames)
{
chomp($name);
#@names = split('need to pass something',$name);
# I want to split every input entry into 3 parts- IdentifyingNumber, Name,Version similarly the way they read.
$name =~ s/^\s+//; #remove leading spaces
$name =~ s/\s+$//; #remove trailing spaces
# here logic goes this way, If the version number has matched, serach for name and if name has matched display its identifying number
print "Identifying number(say $id) of the packge with name(say $pkg)\n";
}
我在緊急要求。任何其他方法也非常感謝。誰能幫幫我嗎??在此先感謝
嘿謝謝Zaid ...其實我想這樣說...非常感謝你 – ybc 2013-02-22 10:10:27