It dosen't directly use perl, but you can do what you want with postscript code and ghostscript to produce a bitmap. Start with this
example program from the
Blue Book and modify it to suit your needs. Then use
ghostscript to produce a suitable
image format.