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
format

sourceIP        DestIP  Protocol        DestPort        SourcePort
Bytes   Packets

Eg

10.0.0.1        10.0.0.5        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
10.0.0.1        80      16005
10.0.0.1        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


http://danconia.org



-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to