in reply to Search for a string in a file and get the string in the next line

Also using embedded DATA (see above). BTW, you should really show what you have tried before asking people to do this for you....

while($line = <DATA>) { if ($line =~ m/PSP-Ri/) { $line = <DATA>; print "Codec = $1\npktSize = $2\nattrib = $3\n\n" if $line =~ m/ +Codec\s(\S+).+pktSize\s(\d+)\sattrib\s(\S+)/; } } __DATA__ 125 09082010 093627.953624:1.01.00.27144.Info .CC: *GCID:0x00000013--I +ngress PSP-Ri 206 09082010 093627.953812:1.01.00.27145.Info .CC: *GCID:0x00000013--C +odec G711 (0x1) pktSize 20 attrib 0x1c00
  • Comment on Re: Search for a string in a file and get the string in the next line
  • Download Code

Replies are listed 'Best First'.
Re^2: Search for a string in a file and get the string in the next line
by Kadam (Initiate) on Oct 11, 2010 at 12:26 UTC
    Thanks for your help, its working.
    I will definitely put the things i have tried before asking next time..