The current script wasn't helpful to me for solving your second phone log parsing problem.

Here is a simple parser for your new problem.

#!/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
UPDATE:
I looked again the the original script. That thing is so wordy that it is hard to figure out what it actually does! However, I think that I did? Anyway here is another parser built upon the same techniques as my first one.

I think there is an obvious difference in clarity.

#!/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
Another update: After looking back yet again at the requirements, you want the printout to be:
sender, receiver1
sender, receiver2
I'll leave that slight modification to you as an exercise (instead of adding a recipient to the line, just print a whole new line) - the above just implements what the original script did! Let us know how you make out with this.

In reply to Re: Redoing a script by Marshall
in thread Redoing a script by PhiThors

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.