penguinfuz has asked for the wisdom of the Perl Monks concerning the following question:
Now for the code snippet (which only counts accesses at the moment):%hash0 = ( $srcIP => \%hash1 ); %hash1 = ( $dstIP => $count );
I have left 2 commented lines in the 'foreach' loop, which hopefully illustrate my thought process.foreach $entry (@entries) { $info = '(some).*(snazzy).*(regexp)'; ($time,$src,$dst) = ($1,$2,$3) if $entry =~ /$info/; $src =~ s/SRC=//g; $dst =~ s/DST=//g; %ips = ( $src => "$dst"); foreach $ws (keys(%ips)) { push @ips, $ips{$ws}; #%visit_count = ( $src => $cnt ); #%src_dst_cnt = ( $ws => \$visit_count ); } } $count{$_}++ for @ips; print "$_\t visits: $count{$_}\n" for (keys(%count)); return @ips;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Counting Occurences, (hash referencing another hash)
by thpfft (Chaplain) on Jul 16, 2002 at 23:26 UTC | |
by penguinfuz (Pilgrim) on Jul 17, 2002 at 23:37 UTC | |
Re: Counting Occurences, (hash referencing another hash)
by mfriedman (Monk) on Jul 16, 2002 at 20:42 UTC |