in reply to How do I count the number of occurrences of each string in an array?

@data = join('', $_ =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d+):(\d+):(\d+)/); is your problem.

You are not adding a new element to the array, you are actually resetting the array each time and then adding one element. So your loop will always find that one element only.

Adding another element to an array is done with the push operator.

push @data, join('', $_ =~ /^(\d\d\d\d)-(\d\d)-(\d\d) (\d+):(\d+):(\d+)/);

Try it and seen if it works "better". Of course using a hash is even better.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics