#!/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 creating the graph my $countLine = 0; # count matched I-lines of text my $g = GraphViz->new(); # create a new graph while (my $line = ) { chomp($line); if( $line =~ m/\bI\b/i ) { # Does $line has an uppercase 'I' anywhere 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$temple"); } } $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 text.\n"; close(INPUTFILE);