Update: Be aware that this has hideous security implications. Also, as Moritz explained to me in reply to Testing error handling that calls "die", there are two forms of eval. But the code given above does what I think you say you want.