use strict; use GraphViz; use XML::Twig; # write $file.jpg and $file.html to files # mkg($xml, $output_file_name) my $file = "modules"; my $map = mkg("@{[]}", $file); my $html = < $map HTML open OUT, ">$file.html"; print OUT $html; close OUT; sub mkg { my ($xml, $file) = @_; my $root = XML::Twig->new()->parse($xml)->root; my $g = GraphViz->new(); render($g, $root); $g->as_jpeg("$file.jpg"); return $g->as_cmap; } sub render { my ($g, $root) = @_; $g->add_node($root->att('name'), URL => $root->att('src'), shape => 'record'); foreach my $child ($root->children) { $g->add_edge($root->att('name') => $child->att('name')); render($g, $child); } } __DATA__