note
GrandFather
<p>Following a little egging on and a simple example from [blokhead] (my thanks for that!) the following code generates the graph I was after. Note that this code uses dot from GraphViz.</p>
<c>
use warnings;
use strict;
my @lines = <DATA>;
my @splitLines = map {[/'(....)'..([-\d]*)\) -> '?(....)'?..([-\d]*)/]} @lines;
my $graphStr = <<GRAPH;
digraph G {
graph [rankdir=LR];
node [shape=rect];
GRAPH
$graphStr .= " $_->[0]$_->[1] -> $_->[2]$_->[3]\n" for @splitLines;
$graphStr =~ s/-(?!>)/_/g;
$graphStr .= "}\n";
open outFile, '>', 'graph.dot';
print outFile $graphStr;
close outFile;
`dot -Tpng -ograph.png graph.dot`;
__DATA__
'TAvi' (-37) -> 'TDMk' (-32)
'TAvi' (-38) -> 'TMrk' (-34)
'TDMk' (-32) -> xfer (-12)
'TDif' (-7) -> xfer (-11)
'TDif' (-8) -> 'TMCF' (-35)
'TDig' (-27) -> 'TSpN' (-33)
'TLCI' (-36) -> 'TAvi' (-37)
'TMCF' (-35) -> 'TLCI' (-36)
'TMrk' (-34) -> xfer (-28)
'TSpN' (-33) -> 'TAvi' (-38)
'TSpN' (-33) -> 'TDMk' (-32)
'TSpN' (-33) -> 'TMCF' (-35)
</c>
<div class="pmsig"><div class="pmsig-461912">
<hr>DWIM is Perl's answer to Gödel
</div></div>
558218
558224