David J. Taylor wrote:
Hey guys,
I'm just starting to lean PERl and the first real job I have to
do with it is pull some stats from Netflow data.

The data comes in the form of a tab delimeted text file in the following

sourceIP DestIP Protocol DestPort SourcePort
Bytes Packets

Eg 17 80 4521
2048 16

What I need to be able to do is take an address and a port and add up
the number of bytes eg
IP Port Bytes 80 16005 443 5575876

Etc, I can see how I could use a hash to do this by using the address
port pair as a key then adding the bytes to that key for every instance
but I'm not sure how to exicute it.
What have you tried? Where did you get stuck? Probably you need to
start with some sort of 'open' to get to the data,

perldoc perlopentut
perldoc -f open

Then you will need some way to divide each line up,

perldoc -f split

Then you will build your hash which it sounds like you know how to do,
but specifically you are going to use the '.' (concatenate) operator and
the '=' (assignment operator), and finally the '+' (addition) operator,

perldoc perlop

So you end up with in pseudo-code:

open file,
while read each line of file,
split line,
add bytes to entry in hash
close file

do whatever you want with the data....which probably involves displaying it,

perldoc -f print


Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
groupbeginners @
postedAug 3, '03 at 11:04p
activeAug 3, '03 at 11:31p



site design / logo © 2022 Grokbase