Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: call tree analysis using perl

by oko1 (Deacon)
on Feb 15, 2012 at 07:07 UTC ( #953852=note: print w/ replies, xml ) Need Help??


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"


Comment on Re: call tree analysis using perl
Select or Download Code
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://953852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2015-07-08 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls