perl OOP - convert perl data structure to js literal or html