That's a problem that can't be solved without running the code, and even approximate solutions are very hard to come by. We've had lots of discussion about that, see
static analysis.
For better parsing I can recommend PPI, which parses Perl as good as you can without executing it.
Perl 6 - links to (nearly) everything that is Perl 6.