Sum Matching Group in Perl

From EggeWiki
Jump to navigation Jump to search

Perl script to find a number in matching lines and report the sum.

<geshi lang="perl"> perl -ne '$sum += $1 if /in (.*) seconds/; END { print $sum }' </geshi>