You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
405 B
Perl

#!/usr/local/bin/perl
$total = 0;
while (1) {
$line = <STDIN>;
if ($line eq "") {
last;
}
chop ($line);
@numbers = split (/[\t ]+/, $line);
foreach $number (@numbers) {
if ($number =~ /[^0-9]/) {
print STDERR ("$number is not a number\n");
}
$total += $number;
}
}
print ("The total is $total.\n");