in reply to generate a chart using the data

Your code does not compile it seems you have one "}" too many. Some variables you declare with my but most of them not?! I think you would benefit from adding:

use warnings; use strict;

It will catch/report various issues with your code.