Unfortunatley, I can't really supply the entire program because you will need the data files to run it, which I'm not allowed to give out. Sorry about that, I know it makes it harder to find the problem.
I have put in the statements use Tk; and use Tk::Graph at the start of the program and the program does display a graph with the correct values, so I know that part of the program works ok. It's just when I tried changing the type of the graph by using menus, it just doesn't change. It displays a pie chart to start off with, with the correct values, but when I chose a selection on the menu the graph doesn't change and I can see the error that i mentioned before in the console. I know the variable for the type of graph is correct because I'm printing it out when that function is called.