#!/usr/bin/perl -n chomp; my @A=split/\s+/,$_; for(@A) { $S+=$_; }; if(eof){ print "$S \n";$S=0 };