$ perl -nE "/: / and $c += (split/: /)[0]; if( eof(ARGV) ){ say qq[SUM.$ARGV =$c]; $c=0 }" tmp_* syntax error at -e line 1, near "+=" syntax error at -e line 1, near "; =" Execution of -e aborted due to compilation errors.