Return to Snippet

Revision: 48063
at June 23, 2011 01:14 by apoz


Initial Code
use strict;
use warnings;
use Math::BigInt;

while(<>)
{
	chomp; 
	s/^ +//g;
	my @values = split /\s+/;
	my $elemento;
	my $sum = Math::BigInt->new('0');
	foreach $elemento (@values)
	{
		$sum->badd(Math::BigInt->new($elemento));
    }
	print "$sum\n";
	$sum=0;
}

Initial URL


Initial Description
Program that sums all the values (including big positive/negative integers)

Initial Title
Space separated values sum

Initial Tags
perl

Initial Language
Perl