in reply to Syntax Checking Perl Code in Strings
If you're willing to live with that, the question has been asked and answered here before, with varying degrees of success.
-- Randal L. Schwartz, Perl hacker