rajkrishna89 has asked for the wisdom of the Perl Monks concerning the following question:
the below perl script(by IVO1) will give the call tree of a c code...but its tracing only upto 2 functions ..help out guys..the snippet is
#!/usr/bin/perl -w use warnings; use strict; my ($tag, %list); while (<DATA>){ next unless /./; if (/^(\w+)/){ $tag = $1; next; } if (/^-- (\w+)/){ push @{$list{$tag}}, $1; } } for my $type (@{$list{main}}){ if ($list{$type}){ for (@{$list{$type}}){ print "main $type $_\n"; } } else { print "main $type\n"; } } __END__ main -- check -- check1 check -- computing -- net check1 -- computing2 -- net2 computing -- community The output should be main check computing community main check net main check1 computing2 main check1 net2 But the output is coming as below: main check computing1 main check net main check1 computing2 main check1 net2
Help out guys
If i use | in the snippet instead of -- , im getting an error , i used escape sequence stil its throwing errors..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tree Analysis
by GrandFather (Saint) on Feb 23, 2012 at 08:17 UTC | |
|
Re: Tree Analysis
by Anonymous Monk on Feb 23, 2012 at 16:33 UTC | |
|
Re: Tree Analysis
by Anonymous Monk on Feb 23, 2012 at 07:54 UTC |