aboutsummaryrefslogtreecommitdiff
path: root/challenge-122/jo-37/perl/ch-1.pl
blob: 6a94454be600f70240ab93b566e45e4040d46a0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl -s

use v5.16;
use warnings;
$| = 1;

# The task states "You are given a *stream* of numbers" which is taken
# to be different from a list.  Thus we expect the data to be provided
# by a file (or STDIN), which could be a pipe.
#
# Call "./ch-1a.pl | ./ch-1.pl" for the task's example.

my ($s, $n);
while (<>) {
    say +($s += $_) / ++$n;
}