Hi KKK, to celebrate your achievement in reaching -100 XP, here's my code...

use strict; # set up @f1 and @f2 to mimic the two files my $f1 = 1; my (@f1, @f2); while(<DATA>){ next unless /\S/; chomp; $f1 = 0 if /^f2$/; push @f1, $_ if $f1; push @f2, $_ unless $f1; } shift @f1; shift @f2; # remove 'f1' and 'f2' # process file1 - basically use headers as hash keys, then fields 1 an +d 2 of each # object as referenced hash keys, with field 3 as value my %headers; my $current_header = 0; foreach(@f1){ # match headers if(/(\|.*){8}/){ $current_header = $_; } # match objects and add to %header (which will be a hash of hashes) # with 3rd object field as value if(/^((?:\|\d+){2})\|(\d+)$/ and $current_header){ ${$headers{$current_header}}{$1} = $2; } } $current_header = 0; foreach(@f2){ # match headers if(/(\|.*){8}/){ $current_header = $_; } # match objects and add to %header (which will be a hash of hashes) # with 3rd object field as value if(/^((?:\|\d+){2})\|(\d+)$/ and $current_header){ if(defined $headers{$current_header} and defined ${$headers{$curre +nt_header}}{$1}){ ${$headers{$current_header}}{$1} += $2; } } } # output the results... foreach my $hkey(keys %headers){ print "Header $hkey\n"; foreach my $okey(keys %{$headers{$hkey}}){ print "Object $okey total:" . ${headers{$hkey}}{$okey} . "\n"; } } __DATA__ f1 #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 |8.2.0.4352.1.2|8.2.0.4352.1.1|0x3|14|6|3|97.232.1.2|6 |7|1|1 |7|2|2 |7|3|3 |5|4|4 |7|5|5 |7|6|6 f2 #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 |8.2.0.4352.1.2|8.2.0.4352.1.1|0x3|14|6|3|97.232.1.2|6 |7|1|10 |7|2|20 |7|3|30 |5|4|40 |7|5|50 |7|6|60

Note that you will have to add file-input (currently reading sample data from <DATA>)

map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20
Tom Melly, pm@tomandlu.co.uk

In reply to Re^9: Adding object identifiers corresponding to each IP and printing them to O/P File. by Melly
in thread Adding object identifiers corresponding to each IP and printing them to O/P File. 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.