The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


CallGraph::Node - represent a subroutine as a node in a call graph


    my $sub1 = CallGraph::Node->new(name => 'main', type => 'internal');
    my $sub2 = CallGraph::Node->new(name => 'mysub', type => 'external');
    print $sub1->dump;
    my @calls = $sub1->calls;
    my @callers = $sub2->callers;
    print $sub1->name; # prints 'main'
    print $sub1->type; # prints 'internal'


This module creates a node within a "call graph" for a program. A node corresponds to a subroutine (or function, method, or whatever it's called), and it has the properties 'name' and 'type'. Subroutines are linked to one another by 'calls'.


my $sub = CallGraph::Node->new(option => value, ...)

Creates a new node. The available options are 'name' and 'type'. These properties really don't mean anything as far as CallGraph::Node is concerned. However, CallGraph expects the name to be unique within a graph, and uses the values 'internal' or 'external'.


Add a link implying that $sub calls $sub2.

my @calls = $sub->calls

Return a list of calls made by $sub. The items in the list are CallGraph::Node items themselves.

my @callers = $sub->callers

Return a list of calls received by $sub. The items in the list are CallGraph::Node items themselves.

my $name = $sub->name;

Get or set the name of the subroutine.

my $type = $sub->type;

Get or set the type of the subroutine.

my $dump = $sub->dump(option => value, ...)

Dump the call graph, starting from $sub, into a string representation. The options are passed to CallGraph::Dumper.




CallGraph, CallGraph::Dumper, CallGraph::Lang::Fortran


Ivan Tubert <>


Copyright (c) 2004 Ivan Tubert. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.