http://www.perlmonks.org?node_id=1020581


in reply to Columnwise parsing of a file

Let's operate under the assumption that you want to sum column 2:
awk '{ sum+=$2} END {print sum}' < matrix.txt
If you want/need to use Perl, and the data in your matrix has fixed length lines... you can unpack it