Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: only print data ie between two lines

by citromatik (Curate)
on Jun 17, 2009 at 10:08 UTC ( #772316=note: print w/ replies, xml ) Need Help??


in reply to only print data ie between two lines

All those while ( $line = <$log> ) seems to me a bad design of your algorithm. If any of the ifs inside them fails, you will consume all the input in a inner while. It seems that at some point one of your regular expressions inside and if statement is failing, thus consuming the rest of the fail. I would also recommend you to use strict and use warnings in your code, specially in code you are testing and (like this case) is giving problems.

I want to count it in between these lines...

The range operator (see perlop) could be an alternative for this. Something like (untested):

while (my $line = <$log>){ if (/recvd AA_BIN_MSG_VER_CHG/ .. /?:(Prepared to Send OK|Sending I +nvalid credential)/){ if (/Handling NSPAdvice for mechanism \[4\]/ .. /whatever_condit +ion_to_reset_this_block/) { if ($line =~ /Authentication mechanism returne +d \[(\d+)\]/) { my $errorCode = $1; print "$errorCode\n"; $ArcotIDError_Count++ if ($errorCode != 0 && $errorCode ! += 1); } } } }

citromatik


Comment on Re: only print data ie between two lines
Select or Download Code
Re^2: only print data ie between two lines
by namishtiwari (Acolyte) on Jun 17, 2009 at 11:33 UTC
    i got this error message when i ran the code with range operator-
    Quantifier follows nothing in regex; marked by <-- HERE in m/? <-- HER +E :(Prepar ed to Send OK|Sending Invalid credential)/ at Count_ErrorCode.pl line +34.
    Thanks NT

      My mistake:

      /?:(Prepared to Send OK|Sending I +nvalid credential)/
      should be
      /(?:Prepared to Send OK|Sending I +nvalid credential)/

      citromatik

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://772316]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-09-17 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (54 votes), past polls