I'm trying to take a csv file and break it up so that i can get an average of one of the fields.

Example Input file: red,5 red,10 red,0 blue,6 blue,1 blue,2

So i would want the output to be: red, 5 blue,3

(assume first column can vary)

My thought was to somehow make an array out of each "type" of the first column so that i can do a sum of the array elements divided by the number of elements in each array, but i'm not sure how to do this. Any help is appreciated.

That is a very bad idea. I will not tell you how to do it. A much better way to read your data from a file is to replace the built-in filehandle DATA with your own filehandle. (Of course, you have to open the file to get the filehandle.) Good Luck, Bill

Because if you do that, you are uselessly using a large chunk of memory to store your file, while the whole point of a file handle is to iterate over the file line by line, to avoid using memory. It is also less efficient, because you are reading each piece of data twice, although the difference may be quite small. Besides, it does not scale well, if your file grows big, at one point or another your program will die for lack of memory.