0: #!/usr/bin/perl 1: # Author : Valter Mazzola, txian@hotmail.com, Italy 2: # Date 25/May/2000, Local time 01:00 AM. 3: 4: # Purpose: 5: # ---> Generate a Graph-ical call tree for your *.pm perl module files. 6: # gra.pl assume that: 7: # 1- you have defined sub(s) with 'sub myfunc {' with 'sub' at the beginning of line. 8: # 2- you call your sub with the '&', i.e. &my_sub (); 9: 10: # The code isn't clean nor perfect ! I've made it in 30 min (including testing) ! 11: 12: # usage: 13: # 1) generate the .dot text graph file definition 14: # perl gra.pl *.pm > myfile.dot 15: # 2) generate the graph using 'dot' executable ( http://www.research.att.com/sw/tools/graphviz/ ) 16: # dot -Tps myfile.dot -o myfile.ps 17: # 3) display the graph 18: # ghostview myfile.ps (choose BBox format) 19: 20: while (<>){ 21: if (/^sub\s+(.*?)\s*\{/){ 22: $cur_sub=$1; 23: } 24: if (/\&([\d\w_]+)\s*\(/){ 25: $c_sub = $1; 26: $n = 0; 27: foreach $k (@{$called_subs{$cur_sub}}) { 28: if ($c_sub eq $k){ 29: $n = 1; 30: last; 31: } 32: } 33: if ($n == 0) { 34: push @{$called_subs{$cur_sub}}, $c_sub; 35: } 36: } 37: } 38: 39: print "digraph G {\n"; 40: print " ratio=auto;\n"; 41: 42: foreach $k (keys(%called_subs)){ 43: $ref_arr = $called_subs{$k}; 44: if (ref($ref_arr)) { 45: foreach $y (@{$ref_arr}){ 46: print " $k -> $y;\n"; 47: } 48: } 49: } 50: 51: print "}\n";
In reply to Generate a Graph-ical call tree for your *.pm perl modules by trony
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |