I have needed to do this multiple times, and always end up re-finding the wheel. ;> I suggest you look at
Chart::Plot, which is designed to do this. As it's based off of the wonderful
GD module, and even defaults to saving as PNG. I also know that it works under Win32 -- I wrote a program doing that just yesterday. ;>
perl -e 'print "I love $^X$\"$]!$/"#$&V"+@( NO CARRIER'