Anyone have cmdline script to generate categories?

I would like to create a perl script to generate categories and sub-categories by performing the appropriate mysql calls.
Has anyone done anything similar that they would be willing to share? It doesn't have to be written in perl, I can translate it over if necessary.
The tricky part seems to be re-generating the left and right tree ids for all categories once a new category has been added.
Also if the Vanilla Devs could point me to the Vanilla php code that generates the mysql for adding a category that would be better than nothing (I've started looking but haven't found it yet).
I saw that there seems to be an AddOn called SimpleAPI that I was hoping could work (though I would rather run a script on the host to avoid any security issues), but it doesn't seem to be available just yet.
Thanks!
Comments
this might give you some clues
vanilla/applications/vanilla/views/settings/managecategories.php
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.