#!/usr/local/bin/perl5.001
#

use webgraph;

# Initialize matlab engine

webgraph::init("matlab42");

# matrix for all hits

$m_all = webgraph::mxCreateFull(24,31,0);
webgraph::mxSetName($m_all,"all");
$all = webgraph::mxGetPr($m_all);

foreach $file (@ARGV) {
    open(FILE,$file);
    print "Processing ",$file,"\n";

    while (<FILE>) {		
	@fields = split(/\s+/, $_);
	next if ($fields[8] != 200);
	@datetime = split(/\[|\/|:/, $fields[3]);
	if ($datetime[2] =~ /Apr/) {
	  webgraph::hit($all, $datetime[1],$datetime[4]);
	}
    }
}

webgraph::PutMatrix($m_all);
webgraph::matlab("figure(1); \
                  surf(all); \
                  view(40,40); \
                  shading interp; \
                  title('All hits'); \
                  set(gca,'xlabel',text(0,0,'Day')); \
                  set(gca,'ylabel',text(0,0,'Hour')); \
                  print -dgif8 stats_all.gif");

# Now provide an interactive mode for viewing
print "MATLAB > ";
while(<STDIN>) { $s = webgraph::matlab($_); print $s,"\n"; print "MATLAB > "; }












