Can you explain little bit , how this regex will work ? 

-Sunita

Date: Mon, 23 Jun 2014 17:12:17 +0530
Subject: Re: Need to Grep only fail count from the Pattern.
From: shajiin...@gmail.com
To: vernekaru...@gmail.com
CC: beginners@perl.org

Hi Uday,
Here's one way to do it.
[code]use strict;use warnings;
while(<DATA>) { chomp;
        next if $. <= 3;                my($uas, $test, $test_name, 
$loop_count, $run_count, $pass_count, $fail_count, $arguments) =  
m/^(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)$/;
        #       my($uas, $test, $test_name, $loop_count, $run_count, 
$pass_count, $fail_count, $arguments);

#       if(m/^(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)\|(.+?)$/) {#      
#           $uas = $1;
#           $test = $2;#            $test_name = $3;#       $loop_count = $4;
#           $run_count = $5;#       $pass_count = $6;#      $fail_count = $7;
#           $arguments = $8;    #       }       
        print "UAS : $uas\n";   print "Test : $test\n"; print "Test Name : 
$test_name\n";
        print "Loop Count : $loop_count\n";     print "Run Count : 
$run_count\n";       print "Pass Count : $pass_count\n";
        print "Fail Count : $fail_count\n";     print "Arguments : 
$arguments\n";       
        print '-' x 30, "\n";   print "SUMMARY\n";      print '-' x 30, "\n";
                if($fail_count > 0) {           print "Result: Fail\n";
        } else {                print "Result: Pass\n"; }
}__DATA__U/A/S|Test|            Test           |Loop  | Run |Pass |Fail    |  
Arguments         |                  Name         |Count|Count|Count|Count 
|-----+----+---------------------------+-----+-----+-----+-----+--------------+---------------
         |  72| Traffic Test             |      1|      11|     11|       0| 
(none)[/code]
[output]UAS :          Test :   72Test Name :  Traffic Test             
Loop Count :       1Run Count :       11Pass Count :      11Fail Count :        
0Arguments :  
(none)------------------------------SUMMARY------------------------------
Result: Pass[/output]

On Mon, Jun 23, 2014 at 3:12 PM, Uday Vernekar <vernekaru...@gmail.com> wrote:

Hi All,


I have following Pattern from which I need to grep only the Fail count and 
store that in a variable.


U/A/S|Test|            Test           |Loop  | Run |Pass |Fail    |  Arguments


         |                  Name         |Count|Count|Count|Count |
-----+----+---------------------------+-----+-----+-----+-----+--------------+---------------
         |  72| Traffic Test             |      1|      11|     11|       0| 
(none)




based on fail count value need to print

if 0------Sucess
if >0------Fail


with Regards
Uday V G



-- 

*********************************************************
Don't ask them WHY they hurt you,
because all they'll tell you is lies 
and excuses.
 Just know they were wrong, and try to move on.
**********************************************************




-- 
best,
Shaji
----------------------------------------------------------------------------------------------------------------------------------------------

Your talent is God's gift to you. What you do with it is your gift back to God.
----------------------------------------------------------------------------------------------------------------------------------------------


                                          

Reply via email to