Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: extract the function call chains of specific length

by choroba (Abbot)
on Jul 11, 2013 at 15:22 UTC ( #1043757=note: print w/ replies, xml ) Need Help??


in reply to extract the function call chains of specific length

No recursion needed. Just keep all the possible paths and extend them $length - 1 times:

#!/usr/bin/perl use warnings; use strict; my $length = 3; my %calls = ( f1 => ['f2'], f2 => [qw[f3 f4]], f3 => [], f4 => ['f5'], f5 => [], ); my @adepts = map [$_], keys %calls; for (1 .. $length - 1) { @adepts = map { my $list = $_; map [@$list, $_], @{ $calls{ $list->[-1] } }; } @adepts; } { local $" = '->'; print "@$_\n" for @adepts; }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: extract the function call chains of specific length
Download Code
Re^2: extract the function call chains of specific length
by dwslovedh (Novice) on Jul 12, 2013 at 12:19 UTC

    I tried, and the script worked! Thanks!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-09-20 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (163 votes), past polls