SAYDIGITS in non-default language in perl AGI

Part of my AGI needs to read back the Caller’s Phone number in Spanish but I cannot figure out how to do so. I know that using Set(CHANNEL(language)=es) works in the dialplan, but because my dialplans are auto-generated, I cannot make a language change before I call the AGI without it being automatically overwritten. Any advice on this issue would be greatly appreciated.

EDIT: GOT IT. Used $AGI->exec("EXEC Set(CHANNEL(language)=es)");

New channel variable requires to do this in a new way:
$AGI->set_variable(’${CHANNEL(language)}’,‘es’);
(tested with Perl AGI module)