On Tue, Jun 24, 2014 at 3:15 AM, Uday Vernekar <[email protected]> wrote:
> Hi all,
>
> I tried this its working fine when we have this pattern at hand,but the
> pattern is in a log file which is very large and i need to grep this pattern
> first from the generated log file then Match.how do i do it?
>
Once $pattern grepped out from log, then:
$fail_count = ( (split(/\Q$pattern/, $_) )[-2];
or maybe:
my $re = qr/\Q$pattern/;
$fail_count = ( split( /$re/, $_) )[-2];
For explanation of "qr", see: Regexp Quote-Like Operators in perlop.
> On Tue, Jun 24, 2014 at 1:30 PM, Uday Vernekar <[email protected]>
> wrote:
>>
>> Thanks everybody will work out the Feasible option from all
>> these......Thanks a lot
>>
>>
>>
>> On Mon, Jun 23, 2014 at 10:12 PM, Charles DeRykus <[email protected]>
>> wrote:
>>>
>>> On Mon, Jun 23, 2014 at 2:42 AM, Uday Vernekar <[email protected]>
>>> 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
>>> >
>>>
>>> Another way:
>>>
>>> while ( <DATA>) {
>>> ...
>>> my $fail_count - ( split( /\|/, $_ ) )[-2];
>>> ...
>>> }
>>>
>>> See: perldoc -f split
>>>
>>> --
>>> Charles DeRykus
>>>
>>> --
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>> http://learn.perl.org/
>>>
>>>
>>
>>
>>
>> --
>> *********************************************************
>> 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.
>> **********************************************************
>
>
>
>
> --
> *********************************************************
> 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.
> **********************************************************
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/