in reply to Search for a string in a file and get the string in the next line
use warnings; use strict; while(<DATA>) { if (/PSP-Ri/) { $_ = <DATA>; # Grab the text after '--' my $pairs = (split('--'))[1]; # Remove that pesky (0x1) $pairs =~ s/\(.*?\)//; # Create a hash from (key<spaces>value) my %hash = split(/\s+/,$pairs); # Print the hash while (my($k,$v) = each(%hash)) { print "$k = $v\n" } } } __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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Search for a string in a file and get the string in the next line
by moritz (Cardinal) on Oct 11, 2010 at 12:16 UTC |