-
Notifications
You must be signed in to change notification settings - Fork 0
/
my-histogram.cgi
49 lines (34 loc) · 1.08 KB
/
my-histogram.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//help taken from https://metacpan.org/pod/Chart::Gnuplot
//also help (but mostly just sass) from https://stackoverflow.com/questions/6350430/histograms-in-chartgnuplot-perl-is-it-possible
use Chart::Gnuplot;
open (FH, $ARGV[0])
|| die "error opening!";
read(FH, $x, 99999);
$argNum = @ARGV;
@args = ();
@freq = ();
for (my $n=1; $n < $numArgs; $n++){
my @x = $ARGV[$i];
push @args, @x =~ /@d/g; //global
my $count = @c;
push @freq, $count;
}
my $chart = Chart::Gnuplot->new(
output => "chart.jpg",
terminal => "jpeg",
title => "Freq. of words in file",
xlabel => "Words",
ylabel => "Freq. in file"
);
my $dataSet = Chart::Gnuplot::DataSet->new(
xdata => \@args,
ydata => \@freq,
style => "histogram",
using => "2:xticlabels(1)",
);
print "Content-type: text/html\n\n";
print "<html><center><head>\n";
print "<title>Gnuplot image</title><h1><font size=\"16\" color=\"red\">CS 410 Webserver</font></h1>\n";
print "</head><body>\n";
print "<img src=\"chart.jpg\">\n";
print "</body></center></html>\n";