% perl -nE "/: / and $c += (split/: /)[0]; if( eof(ARGV) ){ say qq[SUM.$ARGV =$c]; $c=0 }" tmp_* c: Undefined variable.