
wraz
Novice
Dec 14, 2007, 2:50 PM
Post #1 of 21
(9457 views)
|
Issue with search and capture string from a file
|
Can't Post
|
|
This is the contents of my input file. I want to browse through this file and look for "im_im_rdy_samp". If this keyword is found, i want to then pick the string on the next line (in this case FRST_IM_FILE_IO_AMP) and store it in a variable. dogy #1050 fi_dy_watch ("im_im_rdy_samp", `FRST_IM_FILE_IO_AMP.Q, `FRST_IM_FILE_IO_AMP.D, `FRST_IM_FILE_IO_AMP.`CP, `FRST_IM_FILE_IO_AMP.`flag); //---------------Code while(<f1>) { chomp; if($_ =~ /dogy/) { @temp = split(/\(\"/, $_); @temp = split(/\"/, $_); chop($temp[1]); $sync_cap = $temp[1]; print "$sync_cap\n"; } if($_ =~ $sync_cap) { @temp = split(/`/, $_); chop($temp[0]); print "$temp[0]\n"; } } With the raw code posted above, i am able to search for the string (im_im_rdy_samp) and the code displays the first line (fi_dy_watch). I am not able to go to the next line and pick the string starting with this "`" character. I am pretty new to Perl. Can some-body please help me with this? Thanks, wraz
|