Calling an AGI script to remove spaces

Hi,
I’d like to call an agi script to remove all of the invalid characters from a number before it is dialled. I already have the perl script to perform the function. I assume I alter extensions_custom.conf. Could somebody fill me in on the correct way to do this please?

Regards
Ed