I don't know exactly what you are trying to do, but one lateral solution would be: don't print the graph to a file, instead just print it straight to the browser, preceded by an appropriate HTTP header. Then call your perl script directly from within your image tags.