in reply to RegEX Doubt

i dont know if i should create aother thread for this ..but there is another hiccup.for the last "PART4" i need to match it with few strings eg "init code finished ","batch process code started"..

right now i am checking part 4 in if loops ..but it looks messy .is there a better way to match part 4 with say strings from a array @match

Replies are listed 'Best First'.
Re^2: RegEX Doubt
by Laurent_R (Canon) on Aug 19, 2014 at 18:57 UTC
    I think you should do it in two steps. Step 1: just capture everything that comes after [..part 3..] (which you can do when you apply the first regex), and step 2: look at what you've captured presumably in $4 at the end of the line. Otherwise, the rest of your regex (what you have already) might fail because you are trying to match more things, and these things may or may not be there.

      yes i am capturing the fourth part and then checking if any match those keywords ; but i have like n if loops ..is there a better way to search /compare that

        If you have a definite and limited number of possibilities, you might use a hash instead of a series of if ... elsif ... else conditions. Please provide some details for a more knowledgeable answer.