Arifin has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use GraphViz; use strict; use warnings; my $inputfile = $ARGV[0]; open(INPUTFILE, $inputfile) || die "Could not open $inputfile\n"; my $start_run = time(); # get timestamp at the beginning of creatin +g the graph my $countLine = 0; # count matched I-lines of text my $g = GraphViz->new(); # create a new graph while (my $line = <INPUTFILE>) { chomp($line); if( $line =~ m/\bI\b/i ) { # Does $line has an uppercase 'I' anyw +here in it? #print "$line\n"; $countLine++; # Split the I-line into 5 fields my ($timestamp, $field2, $temple, $macaque1, $macaque2) = split ' +', $line; print "$timestamp : $temple : $macaque1 : $macaque2\n\n"; # Add an edge to the graph for this I-line $g->add_edge( $macaque1 => $macaque2, label => "$timestamp\n$temp +le"); } } $g->as_png("1.png"); # save the graph as a png image my $end_run = time(); # get timestamp at the end of creating the graph my $run_time = $end_run - $start_run; print "Job took $run_time seconds. Processed $countLine I-lines of tex +t.\n"; close(INPUTFILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: out of memory error in using GraphViz
by Anonymous Monk on Feb 16, 2009 at 19:55 UTC | |
|
Re: out of memory error in using GraphViz
by pemungkah (Priest) on Feb 24, 2009 at 21:43 UTC |