It appears to me that perlpie's post gives a pretty good example of how to do what the OP asked for. I think it would be helpful if the OP filled some application details. It is certainly possible that the wrong type of data structure has been selected. What would be better is very application specific, so more detail than just there are 5 columns in the file is needed.