How would I use hashes to count the number of times something happens in perl?

Tails

New member
I need to write a program where I take multiple lines, example:
a19:01-01-2009:s1
a31:01-01-2009:s2
a28:01-01-2009:s1
a41:01-01-2009:s1
a35:01-01-2009:s2

and count how many times the first element is linked at the third element. Example: a19 visits a building called s1 on 01-01-2009. a31 visits s2 on 01-01-2009.

I need to use 2 hashes, and count the frequency that axx visits sx and print it. What I have so far is I split the string "a19:01-01-2009:s1" into an array using a split function. My array would equal a19 01-01-2009 s1. I do not need to know any information about the date (01-01-2009) so disregard it.
The format I need to put this in is:

Animal Id Station 1 Station 2
a19 1 0
a31 0 1

Does anyone have any ideas? I'm completely stuck. Thanks.
 
Back
Top