How to read line after finding a pattern?

Posted by Jonathan Low on Stack Overflow See other posts from Stack Overflow or by Jonathan Low
Published on 2011-01-17T07:40:47Z Indexed on 2011/01/17 7:53 UTC
Read the original article Hit count: 190

Filed under:
|

i've got a

"CHANNEL(SYSTEM.DEF.SVRCONN) CHLTYPE(SVRCONN)"

"id=3"

what i want to do is to retrieve the id after i do a search on the file and found the first line.

                open (CHECKFILE8, "$file");
             while (<CHECKFILE8>) #while loop to loop through each line in the file
             {
                chomp; #take out each line by line
             $datavalue = $_; #store into var , $datavalue.
             $datavalue =~ s/^\s+//; #Remove multiple spaces and change to 1 space from the front
             $datavalue =~ s/\s+$//; #Remove multiple spaces and change to 1 space from the back
             $datavalue =~ s/[ \t]+/ /g; #remove multiple "tabs" and replace with 1 space


                if($datavalue eq "CHANNEL(SYSTEM.DEF.SVRCONN) CHLTYPE(SVRCONN)")
                {
                          // HOW TO READ THE NEXT LINE? 
                }

                }
        }

        close(CHECKFILE8);
 }

Thanks

© Stack Overflow or respective owner

Related posts about perl

Related posts about next