The short answer is that, yes, you just print to the browser.
You must begin with a correct Content-type-header, then two
linefeeds and then you print the SWF data to the browser.
Something like
print "Content-type: application/x-shockwave-flash\n\n";
print $SWFdata;
would suffice as a really simple SWF-on-the-fly-generation-CGI-
script. You get the picture.
The part where you generate $SWFdata is obviously the non-trivial
part, but you seem to have solved that already. If I remember
correctly, there is a SWF-creation module that's perhaps worth
checking out.