Tuesday, February 19, 2008

Only perl can parse Perl

I got thrown into yet another new-to-me ball of Perl today and thought it would be really cool if I could kick out a GraphViz graph of all the subroutine calls, like Alan Ferrency attempted back in 2000: sub_graph.pl. Looks like nobody has really pulled this off and sent it to CPAN? #perl-help sent me to PPI which cites Randal's famous line: "the only thing that can parse Perl is perl"!

Bummer... If only I had unlimited free time I could probably get close-enough? I'll email Alan and see if it's moved since 2000. :)

Eric Maki inspired me in Issue 4.1 (Winter 2007) of The Perl Review. But his is Perl op codes, not Perl 5 subroutine calls... -ponder-

1 comment:

brian d foy said...

A graph of subroutine calls is easy because you just run the program and look like I did in Creating Perl Code Graphs, although you'd probably want to plug in a different DProf.

Figuring out what it will do beforehand is a bit of a problem though since it probably depends on the input.

Good luck, and I'm glad you liked the article :)