simple issues really.. just took me a little bit to track them down since i am no perl coder....
1) the key for colors was getting messed up because the index of the color values are all off by one... when you register the colors in the hashmap red should be lines[7] instead of 6, green should be 8 instead of 7, and blue should be 9 instead of 8..
2) when getting the max/min x and max/min y values when you have a "P" label line... the check for greater than or less than is done against lines[1] or lines[2], but the value being stored is lines[4] or lines[5]...
like i said easy enough to fix...