perl -MO=Graph,-text prog.pl >graph.txt
perl -MO=Graph,-vcg prog.pl >graph.vcg xvcg graph.vcg
perl -MO=Graph,-dot prog.pl | dot -Tps >graph.ps
http://www.cs.uni-sb.de/RW/users/sander/html/gsvcg1.html) and Dot (part of the graph visualization toolkit from AT&T:
http://www.research.att.com/sw/tools/graphviz/). It also can produce plain text output (which is more useful for
debugging the module itself than anything else, though you might be able to
make cut the nodes out and make a mobile or something similar).
O module to run correctly:
perl -MO=Graph,-opt,-opt,-opt program.pl OR perl -MO=Graph,-opt,obj -e 'print "Hello, world!\n"' OR EVEN perl -e 'use O qw(Graph -opt obj obj); print "hi!\n";'
Obj is the name of a perl variable whose contents will be examined. It can't be
a my() variable, and it shouldn't have a prefix symbol
('$@^*'), though you can specify a package -- the name will be used to look
up a GV, whose various fields will lead to the scalar, array, and other
values that correspond to the named variable. If no object is specified,
the whole main program, including the CV that points to its pad, will be
displayed.
Each of the the opts can come from one of the following (each set is mutually exclusive; case
and underscores are insignificant):
my() variables (as well as compiler temporaries)), structures
that keep track of code (CVs), and a variety of others. The default is to
display all these too, to give a complete picture, but if you aren't in a
holistic mood, you can make them disappear.
@INC and %ENV, and so on. To prevent information
overload, then, the display of stashes is disabled by default.
Pb SVs_PADBUSY reserved for tmp or my already
Pt SVs_PADTMP in use as tmp
Pm SVs_PADMY in use a "my" variable
T SVs_TEMP string is stealable?
O SVs_OBJECT is "blessed"
Mg SVs_GMG has magical get method
Ms SVs_SMG has magical set method
Mr SVs_RMG has random magical methods
I SVf_IOK has valid public integer value
N SVf_NOK has valid public numeric (float) value
P SVf_POK has valid public pointer (string) value
R SVf_ROK has a valid reference pointer
F SVf_FAKE glob or lexical is just a copy
L SVf_OOK has valid offset value (mnemonic: lvalue)
B SVf_BREAK refcnt is artificially low
Ro SVf_READONLY may not be modified
(i) SVp_IOK has valid non-public integer value
(n) SVp_NOK has valid non-public numeric value
(p) SVp_POK has valid non-public pointer value
S SVp_SCREAM has been studied?
V SVf_AMAGIC has magical overloaded methods
V OPf_WANT_VOID Want nothing (void context)
S OPf_WANT_SCALAR Want single value (scalar context)
L OPf_WANT_LIST Want list of any length (list context)
K OPf_KIDS There is a firstborn child.
P OPf_PARENS This operator was parenthesized.
(Or block needs explicit scope entry.)
R OPf_REF Certified reference.
(Return container, not containee).
M OPf_MOD Will modify (lvalue).
T OPf_STACKED Some arg is arriving on the stack.
* OPf_SPECIAL Do something weird for this op (see op.h)