We have the Log Data in 2 log files viz :- "File1.dat" and "File2.dat". The data in both the Files is as follows:

---------------------------------------------------------------------------------------------------------------

1) File1.dat

CLASS: Performance Event Reports

START:2006/11/21 08:30:00 Tue; STOP:2006/11/21 09:00:00 Tue;

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|10|2|105

|36242050|58

|5|1|6

|5|2|0

|5|3|0

|5|4|6

|5|5|0

|5|6|0

|38929186|58

|5|1|5

|5|2|0

|5|3|0

|5|4|5

|5|5|0

|5|6|0

|33554850|58

|5|1|184

|5|2|0

|5|3|16

|5|4|184

|5|5|0

|5|6|0

#END

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|11|2|238

|36241618|40

|7|1|1486

|7|2|0

|7|3|0

|7|4|0

|7|5|0

|7|6|5315

|36241858|40

|7|1|2996

|7|2|0

|7|3|0

|7|4|0

|7|5|0

|7|6|8880

|36241842|40

|7|1|16862

|7|2|133

|7|3|0

|7|4|42

|7|5|0

|7|6|75938

#END

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|14|6|3

|97.232.1.2|6

|7|1|1553

|7|2|13

|7|3|1870

|5|4|0

|7|5|22087238

|7|6|73162814

|97.232.1.4|6

|7|1|1877

|7|2|14

|7|3|2200

|5|4|0

|7|5|185424

|7|6|1530455

|97.232.1.3|6

|7|1|1898

|7|2|12

|7|3|2210

|5|4|0

|7|5|1280410

|7|6|6526620

#END

2) File2.dat

CLASS: Performance Event Reports

START:2006/11/21 09:00:00 Tue; STOP:2006/11/21 09:30:00 Tue;

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|10|2|141

|33554850|58

|5|1|66

|5|2|0

|5|3|0

|5|4|66

|5|5|0

|5|6|0

|36242050|58

|5|1|181

|5|2|0

|5|3|0

|5|4|181

|5|5|0

|5|6|0

|36241938|58

|5|1|10

|5|2|0

|5|3|0

|5|4|10

|5|5|0

|5|6|0

#END

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|11|2|250

|38928802|40

|7|1|67926

|7|2|4989

|7|3|4542

|7|4|12414

|7|5|9955

|7|6|800193

|36241858|40

|7|1|88640

|7|2|3661

|7|3|7150

|7|4|7546

|7|5|8717

|7|6|882378

|36241842|40

|7|1|1055

|7|2|0

|7|3|0

|7|4|0

|7|5|0

|7|6|5009

#END

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|14|6|3

|97.232.1.2|6

|7|1|1545

|7|2|14

|7|3|1981

|5|4|0

|7|5|18613745

|7|6|81837527

|97.232.1.4|6

|7|1|1931

|7|2|9

|7|3|2367

|5|4|0

|7|5|4326223

|7|6|19359092

|97.232.1.3|6

|7|1|1889

|7|2|13

|7|3|2322

|5|4|0

|7|5|6642322

|7|6|30404562

#END

-----------------------------------------------------------------------------------------------------------

Need to perform the following operations and store the resultant output in the file "Output.dat".

The following to be done in both the files for the operations to be performed :-

1) In the first instance, we have to match the headers upto the first 4 positions and neglect the last 2 digits. For eg:- we have the first headers respectively in both the files viz |8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|10|2|105 and |8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|10|2|141. They are similar, as digits are same upto the first 4 positions.

Note :- Now as the first headers are same, we can only concentrate on these, as for rest of the matched headers, the corresponding operations would be the same.

2) After this, we go for the second matching. Under each header, there are sub-headers. We compare the sub-headers. There are 3 sub-headers in File1.dat viz:- 36242050|58, |38929186|58 and |33554850|58. In File2.dat, the 3 sub-headers are :- |33554850|58, |36242050|58 and |36241938|58.

We compare the sub-headers for comparing the respective digits (irrespective of their Location like 1st, 2nd, 3rd positions of each header) in both the Files.

For eg:- In File1.dat, the 1st and 3rd sub-headers viz.:- 36242050|58 and |33554850|58 exactly match respectively in File2.dat, the 2nd and 1st sub-headers viz.:- |36242050|58 and |33554850|58.

Now we are done with the 2nd matching.

3) Object or Message Object is data (in the Form |5|1|6) in a Packet(a Networking Term). For eg:- |5|1|6 is one Object. Similarly |5|1|66 is another Object and so on. Identifier is one of the component in the Message Object. For eg:- in the Object |5|1|6, 5 is the first identifier, 1 is the second identifier and 6 is the third identifier. There are 'N' number (N being a real number) of Message Objects (I have mentioned just 6) under each header and sub-header.

Now the third operation being :-

For each matched sub-header for eg:- lets say 36242050|58 in both the Files, add the identifiers of objects (ignoring the 1st and 2nd place identifiers which are always common and adding only the identifiers at the 3rd place).

For eg here :-

For File1 :-

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|10|2|105

|36242050|58

|5|1|6

|5|2|0

|5|3|0

|5|4|6

|5|5|0

|5|6|0

For File2:-

|36242050|58

|5|1|181

|5|2|0

|5|3|0

|5|4|181

|5|5|0

|5|6|0

Now adding, we have :-

|5|1|6 + |5|1|181 = |5|1|187

|5|2|0 + |5|2|0 = |5|2|0

|5|3|0 + |5|3|0 = |5|3|0

|5|4|6 + |5|4|181 = |5|4|187

|5|5|0 + |5|5|0 = |5|5|0

|5|6|0 + |5|6|0 = |5|6|0

4) Now the fourth operation:- print the output for the operation above (which is one of the part of the total output) in an Output File "Output.dat" as below :-

#LOGNUM|1|OPERATIONAL

|O%:CCLN-1-CBS1

|8.2.0.4352.1.1|8.2.0.4352.1.1|0x3|10|2|105

|36242050|58

|5|1|187

|5|2|0

|5|3|0

|5|4|187

|5|5|0

|5|6|0

Request you to please give your very valuable Inputs.

Thanks and Regards,

KiranKumar K.

READMORE tags added by Arunbear


In reply to Adding object identifiers corresponding to matched headers and sub-headers. by Kiran Kumar K V N

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.