Isn't Perl wonderful!
Chris Benson
chrisb at jesmond.demon.co.uk
Sun Oct 13 05:21:39 CDT 2002
PROBLEM: Oracle Financials patches
- hundreds of patches need to be applied
- there are strict order dependencies between the patches
- dependency data is scattered through multiple documents for each patch.
SOLUTION: GraphViz+Perl
- 30 line program to prepare the data and plot the result as PostScript
or PNG.
- All the hard word done by GraphViz.
- It took longer to find and list the dependencies than write the program.
PREREQUISITES:
- The GraphViz module has a few dependencies of its own. The main one
is the graphviz package from http://www.graphviz.org/.
Ta-raaaah! :-
#!/usr/local/bin/perl -w
use strict;
use GraphViz;
my $G = GraphViz->new(directed => 0, random_start => 1, epsilon => 0.01,
no_overlap => 1, width => 7.5, height => 11);
my %Seen;
sub my_add_node {
my ($node, $label) = split /\//, uc shift;
$G->add_node($node) unless exists $Seen{$node};
++ $Seen{$node};
$G->add_node($node, label => $label) if defined $label;
return $node;
}
while (<DATA>) {
next if /^\s*#/;
my($node, @deps) = split;
$node = my_add_node($node);
foreach my $dep (@deps) {
$dep = my_add_node($dep);
$G->add_edge($node => $dep, dir => 'back');
}
}
# $G->as_png('graph.png');
print $G->as_ps;
exit 0;
# test data: patch-number/Name
# patch prereq prereq prereq ...
__END__
2141471 2291496 2290149
2290149
2291496
2085104 AR.D
2243908/CE.G 2141471 2032040
1769725 1741469/GMS.F 1900156/GL.E
2336010 2085104/ssf.5.5.2c
2166451/GMS.I 1945611/AD.E 2177442 2032040/WF2.6 2028970/PA.H
2028970/PA.H 1324710 1344328/PER.A
2282144
2482020 PA.G
2205084
2297041 2205084
2322330/RG.E
1642167
2182672/XLA.E
--
Chris Benson
More information about the Tyneside-pm
mailing list