Update:: If I execute using application 'System' instead of application 'Perl' in the dialplan it works finie...

P.S.
Here's the script again for reference...
http://pastebin.freeswitch.org/20577

--
I'd love to change the world, but they wont gimme the source code to it