in reply to GD::Graph called from cgi-bin

When the browser encounters an IMG-tag, it will issue a request for the image data.   By far the easiest way to see how this works is to use a client-side debugger such as Firebug.

If you want your Perl program to serve the image-data, the key factor that you must contend with is properly setting the content-type and other relevant HTML tags in the HTTP response-packet that you send back.   Of course, every Perl HTTP-package provides the means to do this.

As it happens, I like to “cheat” this.   If the image that needs to be sent back is literally just “the content of such-and-such static disk file,” then I like to arrange the Apache configuration so that Apache can directly do what Apache already does best:   serving static files.   I only send to the Perl script things that actually demand a programmatic response.

I suggest (from experience...) that the best approach to take here is two-step.   First, observe and study what needs to be done, by watching existing HTTP interactions between clients and servers using the debugging tools I have described.   Then, look at how to generate these responses with Perl, and at how to prepare Apache (or IIS) configurations so as to route the various kinds of requests in appropriate directions.   It might feel a bit bewildering at first, heh..., but it’s really not complicated at all.