dotfiles/bin/movingaverage
michener 29c7fd1814 Update from eponine -- new screenrc, et al
git-svn-id: http://photonzero.com/dotfiles/trunk@24 23f722f6-122a-0410-8cef-c75bd312dd78
2008-09-22 23:10:35 +00:00

23 lines
390 B
Perl
Executable file

#!/usr/bin/perl
$averageto = $ARGV[0];
for ($i = 0; $i < $averageto + 1; $i++) {
$_ = <STDIN>;
chomp;
$temp[$i] = $_;
}
while (<STDIN>) {
chomp;
$x = 0;
for ($i = 0; $i < $averageto + 1; $i++) {
$x += $temp[$i];
}
$x = $x + $_;
$x = $x / ($averageto + 1);
print "$x\n";
for ($i = 0; $i < $averageto; $i++) {
$temp[$i] = $temp[($i + 1)];
}
$temp[($averageto -1)] = $_;
}