Raghupathy wrote: > Hi All, > > I have a text file as shown below. How do I match > patterns like the following: > > Pattern to be matched: > ========================= > #ifndef def > ...... (anything except #if) > #else def > ....... (anything except #if) > #endif def > > > My Input Data: > ===================================================== > #ifndef def > DELETE sys1..tbl1 > #endif def > > SELECT col1, col2, col3 > #ifndef def > FROM sys1..tbl1 > #else def > FROM sys1..tbl2 > #endif def > WHERE schdid is not null > > ===================================================== > > What I tried is below (but did not work since it > captured patterns which had "#if" nested within the > main pattern). > > $line1 =~ > m/#ifndef\s+def(.*?)#else\s+def(.*?)#endif\s+def/isg >
I thought I knew what you meant, but then I changed my mind! If your input file is, say statement1; #ifdef def1 statement2; #ifdef def2 statement3; #else statement4; #endif statement5; #else statement6; #ifdef def3 statement7; #else statement8; #endif statement9; #endif What is it that you want to capture? Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]