docs
[mirrors/Programs.git] / c / goertzel / histogram.pl
1 #!/usr/bin/env perl
2 #This script processes output of goertzel and paints histogram
3
4 use strict;
5 use warnings;
6 use Term::ReadKey;
7
8
9 sub bar($$$) {
10 my ($value,$max,$prefix) = @_;
11 my ($wchar, $hchar, $wpixels, $hpixels) = GetTerminalSize();
12 $value = ($value/$max)*($wchar-length($prefix));
13 return $prefix."#" x $value." " x ($wchar-$value-length($prefix));
14 }
15
16 sub trim($) {
17 my $string = shift;
18 $string =~ s/^\s+//;
19 $string =~ s/\s+$//;
20 return $string;
21 }
22
23 print "\033[H\033[2J";
24
25 my @header = split('\t', <STDIN>);
26
27 while(<STDIN>) {
28 my @values = split('\t', $_);
29 my $i=0;
30 print "\033[H";
31 foreach my $i (1..$#values) {
32 print bar($values[$i],50,sprintf("%8s ",trim($header[$i])))."\n";
33 }
34 print "Time: ".$values[0]." \n";
35 print " \n";
36 }
37
38 exit 0;
This page took 0.273536 seconds and 4 git commands to generate.