---- #!/usr/bin/perl -w -Iperl use strict; + + $| = 1; + + my $globalCounter = 0; my %mon_log; + + my $month = "03"; my $year = "2004"; + + + + open(REPORTFILE, "inputfile") or die "$0: Can't open data file : $! +\n"; # open file + + open(DEBUGFILE, "> debug") or die "$0: Can't open debug file : $!\n +"; # open file + + while(<REPORTFILE>){ + + my($fmt_proto, $fmt_dest_ip, $fmt_src_ip, $fmt_dest_port, $fmt_src +_port, $fmt_drp_packets, $fmt_country) = split(/\s+/); + + print DEBUGFILE "{$month.$year}{$fmt_proto}{$fmt_dest_ip}{$fmt_des +t_port}{$fmt_src_ip}{$fmt_src_port}\n"; + + if(!exists($mon_log{$month.$year}{$fmt_proto}{$fmt_dest_ip}{$fmt_d +est_port}{$fmt_src_ip}{$fmt_src_port})){ $globalCounter += 1; print DEBUGFILE $globalCounter,"\n"; } + + $mon_log{$month.$year}{$fmt_proto}{$fmt_dest_ip}{$fmt_dest_port}{$ +fmt_src_ip}{$fmt_src_port} += $fmt_drp_packets; } + + close(REPORTFILE); close(DEBUGFILE); exit(0); --- input file format: icmp 123.45.67.89 123.76.243.210 0 11 + 1 United States icmp 142.156.23.54 12.254.215.10 0 11 + 1 United States
In reply to puzzling seg fault by ttown1079
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |