perl reading from mysql, processing and outputting results