in reply to Turning a script into a solid block of code
Independently Parsing Perl shows how to use PPI and Perl::Squish to do something similar that will probably compile.