use warnings; use strict; while() { if (/PSP-Ri/) { $_ = ; # Grab the text after '--' my $pairs = (split('--'))[1]; # Remove that pesky (0x1) $pairs =~ s/\(.*?\)//; # Create a hash from (keyvalue) 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--Ingress PSP-Ri 206 09082010 093627.953812:1.01.00.27145.Info .CC: *GCID:0x00000013--Codec G711 (0x1) pktSize 20 attrib 0x1c00