http://www.perlmonks.org?node_id=953852


in reply to call tree analysis using perl

Given how fragile and experimental Devel::Calltree is reported to be, and assuming that your data isn't any more complex than what you're showing (large assumption, I know), you could try unwrapping them yourself.

#!/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__ display -- audit -- bass elucent -- audit -- check main -- display -- elucent -- audit -- check

Output:

main display audit main display bass main elucent audit main elucent check main audit main check
-- 
I hate storms, but calms undermine my spirits.
 -- Bernard Moitessier, "The Long Way"

Replies are listed 'Best First'.
Re^2: call tree analysis using perl
by rajkrishna89 (Acolyte) on Feb 15, 2012 at 16:18 UTC

    Hi oko1 , wonderful dude, I tried the above snippet and it works perfect. but i got a doubt , i tried expanding the function names and still i got only three functions at a time..

    display -- audit -- bass elucent -- audit -- check main -- display -- elucent -- audit -- check audit -- hi_oko1 Output: So the new output should be like this: main display audit hi_oko1 main display bass main elucent audit hi_oko1 main elucent check main audit But still im getting the same o/p:- main display audit main display bass main elucent audit main elucent check main audit hi_oko1
Re^2: call tree analysis using perl
by Anonymous Monk on Feb 15, 2012 at 08:49 UTC

    Hi okol thank u for the response but im getting error msgs

    Name "main::Data" used only once readline() on unopened filehandle DATA

      As there is no Data in that script, I suppose you wrote

      while (<Data>){

      This is not the same as while (<DATA>){ because Perl is case-sensitive.

        I used DATA also but still its throwing up the same error.