Sounds like something best suited to a 3D approach. I'd personally look for a specialized tool that can read in your data and map it in 3D, rather than trying to reinvent the wheel in Perl. For instance, Mathematica if you prefer professional applications that can do everything, or there's lots of assorted freeware, shareware, or cheap software that might include something you could use:
http://www.dmoz.org/Science/Math/Software/Graphing/