Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: call tree analysis using perl

by oko1 (Deacon)
on Feb 15, 2012 at 07:07 UTC ( [id://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"

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://953852]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-26 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found