Here is a simple parser for your new problem.
UPDATE:#!/usr/bin/perl -w use strict; my $current_call=""; my $current_line=""; while (<DATA>) { my ($call, $partyID) = /Call="(\w+)".*partyID="(\w+)"/; next unless defined $partyID; if ( $call ne $current_call) # new call record { print "$current_line\n" if $current_line ne ""; $current_call = $call; $current_line = $partyID; } else # the receiver partyID { $current_line .= " $partyID"; } } print "$current_line\n"; =prints 3855 OutOfArea 2863 2717 =cut __DATA__ 08:17:12.245 ( 1528: 4112) [TMS] AddMediaStreamFromCDS : Media Stream + Event from Remote Server is logged hr=0x00000000 08:17:12.245 ( 1528: 4132) [TMS] CNccCdrLog::ProcessMediaStreamReques +t: 0 08:17:17.843 ( 1528: 4132) [TMS] CCallEntryMsg::WriteCallData - valid +ating CDR privacy for Call="002000199994e4ea9030010491ae13d", partyID +="3855", CtrlPartyID="" 08:17:17.843 ( 1528: 4132) [TMS] CCallEntryMsg::WriteCallData - valid +ating CDR privacy for Call="002000199994e4ea9030010491ae13d", partyID +="OutOfArea", CtrlPartyID="" 08:17:17.844 ( 1528: 4132) [TMS] CCallEntryMsg::WriteCallData - EndOf +List: after 3 entries, hr=0xC1170A2E 08:17:21.479 ( 1528: 4132) [TMS] CCallEntryMsg::WriteCallData - valid +ating CDR privacy for Call="00b0001288b4da335dc0010491ad632", partyID +="2863", CtrlPartyID="" 08:17:21.479 ( 1528: 4132) [TMS] CCallEntryMsg::WriteCallData - valid +ating CDR privacy for Call="00b0001288b4da335dc0010491ad632", partyID +="2717", CtrlPartyID="" 08:17:21.479 ( 1528: 4132) [TMS] CCallEntryMsg::WriteCallData - EndOf +List: after 3 entries, hr=0xC1170A2E 08:17:21.640 ( 1528: 4112) [TMS] NccDtcpMsgLegState : Processing L +eg State Event
I think there is an obvious difference in clarity.
Another update: After looking back yet again at the requirements, you want the printout to be:#!/usr/bin/perl -w use strict; my $current_line=""; while (<DATA>) { if ( /Distribute message from:\s*(.*)\s*$/ ) { print "$current_line\n" if $current_line ne ""; $current_line = $1; } elsif ( /Distributed:\s*(\w+)\s*$/) { $current_line .= ",$1"; #add a receipient } } print "$current_line\n"; =prints olgal (olgal),TulaM ElizabethY (ElizabethY),KaseyT,KirkL marcc (marcc),JasonE =cut __DATA__ 16:32:59 256 Distribute message from: olgal (olgal) 16:32:59 256 Begin distribution to 1 users 16:32:59 256 Distributed: TulaM 16:32:59 408 Notifying client at: 192.168.1.103 UDP port 65534 16:32:59 408 Notifying client at: 172.16.201.27 UDP port 1109 16:32:59 408 Notifying client at: 172.16.201.27 UDP port 1109 16:33:03 152 getQuickMessagesResponse is too large: [EA04] 16:33:03 176 Notifying client at: 10.0.2.159 UDP port 61774 16:33:06 256 Processing update: item record (christinam) 16:33:06 176 Notifying client at: 10.0.2.159 UDP port 61774 16:33:06 256 Purge Execution Record #308860 (christinam) 16:33:06 176 Notifying client at: 10.0.2.159 UDP port 61774 16:33:06 176 Distribute message from: ElizabethY (ElizabethY) 16:33:06 256 Notifying client at: 10.0.200.61 UDP port 2257 16:33:06 176 Begin distribution to 2 users 16:33:06 176 Distributed: KaseyT 16:33:06 176 Distributed: KirkL 16:33:06 256 Notifying client at: 10.0.200.30 UDP port 49857 16:33:06 256 Notifying client at: 10.0.200.83 UDP port 62849 16:33:06 256 Notifying client at: 10.0.200.61 UDP port 2257 16:33:11 256 Notifying client at: 10.0.13.7 UDP port 56097 16:33:11 256 Notifying client at: 10.0.13.7 UDP port 64665 16:33:11 176 Distribute message from: marcc (marcc) 16:33:11 176 Begin distribution to 1 users 16:33:11 176 Distributed: JasonE
In reply to Re: Redoing a script
by Marshall
in thread Redoing a script
by PhiThors
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |