一次搜索多行

时间:2013-07-08 11:06:06

标签: perl

Users of SSS:  (Total of 1 license issued;  Total of 0 licenses in use)

Users of DesignWare-Regression:  (Total of 1 licenses issued;  Total of
0 licenses in use)

Users of FusionVantageLmcInterface:  (Total of 2 licenses issued;
Total of 0 licenses in use)

Users of LMCSwift_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of SNPS-Assertions:  (Total of 4 licenses issued;  Total of 0
licenses in use)

Users of VCSAMSCompiler_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VCSAMSRuntime_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VCSPostProcDebugger_Net:  (Total of 2 licenses issued;  Total
of 0 licenses in use)

Users of VCSTools_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VCSiCompiler_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VCSiRuntime_Net:  (Total of 2 licenses issued;  Total of 2
licenses in use)

Users of VT_Assertions:  (Total of 4 licenses issued;  Total of 0
licenses in use)

Users of VT_AssertionsRuntime:  (Total of 2 licenses issued;  Total of
0 licenses in use)

Users of VT_Coverage:  (Total of 2 licenses issued;  Total of 0 licenses in use)

Users of VT_CoverageRuntime:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VT_CoverageURG:  (Total of 3 licenses issued;  Total of 0
licenses in use)

Users of VT_Testbench:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VT_TestbenchRuntime:  (Total of 2 licenses issued;  Total of
2 licenses in use)


Users of VT_Visual:  (Total of 2 licenses issued;  Total of 2 licenses in use)

Users of XVCSDebugger:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of vera_comp:  (Total of 2 licenses issued;  Total of 0 licenses in use)

Users of vera_debug:  (Total of 2 licenses issued;  Total of 0 licenses in use)

Users of vera_rtime:  (Total of 2 licenses issued;  Total of 0 licenses in use)

我有这样的数据。在这里,我想要产品名称,颁发的许可证数量,使用的许可证数量......我可以得到它...请帮助

这就是我现在所拥有的。

    if ($_=~ m/.*users\s+of\s+(.*)\:\s+(Total\s+of\s+(\d)\s+licenses.*\;\A*\s+total\s+of\A*\‌​s+(\d)\A*\s+licenses\s+.*)/gmi)

{print "$1,$2,$3}";

1 个答案:

答案 0 :(得分:1)

希望这符合您的需求。你已经超越了某些方面,我已经解决了这些问题。

$Data = join '',<DATA>;
while ( $Data =~
    m/\G\s*Users\s*of\s*(.+?)\s*:
         \s*\(Total\s*of\s*(\d+)\s*licenses\s*issued\s*\;
         \s*Total\s*of\s*(\d+)\s*licenses\s*in\s*use\s*\)\s*/gmix)
     {
         print "$1,$2,$3\n";
     }
__DATA__
Users of vera_rtime:  (Total of 2 licenses issued;  Total of 0 licenses in use)

Users of DesignWare-Regression:  (Total of 1 licenses issued;  Total of
0 licenses in use)

Users of FusionVantageLmcInterface:  (Total of 2 licenses issued;
Total of 0 licenses in use)

Users of LMCSwift_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)


Users of SNPS-Assertions:  (Total of 4 licenses issued;  Total of 0
licenses in use)

Users of VCSAMSCompiler_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VCSAMSRuntime_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)

Users of VCSPostProcDebugger_Net:  (Total of 2 licenses issued;  Total
of 0 licenses in use)

Users of VCSTools_Net:  (Total of 2 licenses issued;  Total of 0
licenses in use)