Uday Vernekar 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 > > --
This is how I'd do it. #!/usr/bin/perl use 5.10.0; use strict; use warnings; # throw away the first 3 lines <DATA> for 1..3; # grab the wanted row of data my $data = <DATA>; # extract the "failed" field i.e., 6th field my $failed = (split /\|/, $data)[5]; # strip leading spaces $failed =~ s/^\s+//; if ($failed) { say 'Failed'; } else { say 'Sucsess'; } __DATA__ U/A/S|Test| Test |Loop | Run |Pass |Fail | Arguments | Name |Count|Count|Count|Count | -----+----+---------------------------+-----+-----+-----+-----+--------------+--------------- | 72| Traffic Test | 1| 11| 11| 0| (none) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/