Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^8: Adding object identifiers corresponding to each IP and printing them to O/P File.

by Kiran Kumar K V N (Initiate)
on Jan 12, 2007 at 10:05 UTC ( #594338=note: print w/replies, xml ) Need Help??


in reply to Re^7: Adding object identifiers corresponding to each IP and printing them to O/P File.
in thread Adding object identifiers corresponding to each IP and printing them to O/P File.

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Re^8: Adding object identifiers corresponding to each IP and printing them to O/P File.

Replies are listed 'Best First'.
Re^9: Adding object identifiers corresponding to each IP and printing them to O/P File.
by NovMonk (Chaplain) on Jan 12, 2007 at 13:46 UTC
    Kiran,

    This is not a free coding service site. Do you just not get that? It's a place for learning how to code in Perl. Your posts to date do not show any effort in that regard. And even if some helpful monk posts code for you, your posts to date do not show any likelihood that you will understand their solutions well enough to modify such code to fit your own situation.

    I've been where you are-- overwhelmed by a task and a need to find a solution fast. I even seem to recall getting downvoted on my first attempts at asking a question here, for not showing any work or effort of my own. Here's what I suggest you do now:

    1. Hire someone to perform the task you need done (or) if you're in a class, read your textbook and talk to your professor or fellow classmates
    2. Invest in a copy of Learning Perl and work your way through a good chunk of it on your own.
    3. Come back here and work your way through some of the many fine tutorials on this site.

    I'm sure that by now Many Monks have pointed you to various "How do I post a question effectively" type nodes, so I will not waste my time with that here. But I do wish you to know that while we welcome all newcomers, you are going to continue to be frustrated by this site and our responses to your queries until you make some effort to play by the rules of the community.

    Pax,
    NovMonk

Re^9: Adding object identifiers corresponding to each IP and printing them to O/P File.
by bart (Canon) on Jan 13, 2007 at 12:36 UTC
    Kiran,
    Whenever anybody, including myself, asks you for a bit more explanation, you simply don't reply.

    So my answer is simply, to put it politely: No.

Re^9: Adding object identifiers corresponding to each IP and printing them to O/P File.
by Melly (Hermit) on Jan 12, 2007 at 13:32 UTC

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://594338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2022-06-29 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (96 votes). Check out past polls.

    Notices?