Histogram improvements
[mirrors/Programs.git] / c / goertzel / histogram.pl
CommitLineData
b1620709
TM
1#!/usr/bin/env perl
2#This script processes output of goertzel and paints histogram
3
4use strict;
5use warnings;
6use Term::ReadKey;
7
8
9sub 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
16sub trim($) {
17 my $string = shift;
18 $string =~ s/^\s+//;
19 $string =~ s/\s+$//;
20 return $string;
21}
22
23print "\033[H\033[2J";
24
25my @header = split('\t', <STDIN>);
26
27while(<STDIN>) {
28 my @values = split('\t', $_);
29 my $i=0;
30 print "\033[H";
31 foreach my $i (1..$#values) {
06619070 32 print bar($values[$i],50,sprintf("%8s ",trim($header[$i])))."\n";
b1620709
TM
33 }
34 print "Time: ".$values[0]." \n";
35 print " \n";
36}
37
38exit 0;
This page took 0.132641 seconds and 4 git commands to generate.