If I were you I would go the AGI way. Use ruby, python, php, perl, java, c# or even erlang. Aything but the asterisk dialplan commands. There is no sense in putting yourself through that pain.