It would probably be quicker to start with something written in Perl and make that into a global or plugin.
I did a quick search and there are a few sample scripts around that might be worth looking at.
I did a quick search and there are a few sample scripts around that might be worth looking at.