One possible source of "wierdness" with mod_perl is the good old "nested subroutines" problem. I think what can happen with EmbPerl is each EmbPerl construct appears internally as a sub. (tho I have been known to be wrong in the past). Look in your error log - see it there is any "Variable $x will not stay shared at . . ." messages.