#!/usr/bin/env perl use utf8; ############################################################################### # This program computes the sum of a list of float values on STDIN. # # Copyright © 2016 Richard Lesh. All rights reserved. ############################################################################### use Error::Simple; use Nice::Try; use Utils; use strict; use warnings; MAIN: { my $line; my $d; my $total = 0; while ($line = ) { $line = Utils::trim($line); try { $d = Utils::stod($line); $total += $d; } catch (Error::Simple $ex) { if (length($line) > 0) { print "Can't parse input: ", $line, "\n"; } } } print Utils::messageFormat("\{0:g\}", $total), "\n"; }