use strict; #-- Define in/out files my $inf = "test.txt" ; #-- variables and handles my $line; my $a; my $b; my @result; @row = ((0) x 361); @column = ((0) x 361); my @Matrix = ( @row, @column); #--Open the input and output files open (IN, "$inf") || die "Can't read $inf"; while ($line = ) { @result = split(/\s+/, $line); $a = $result[0]; $a = int($phi); $b = $result[1]; $b = int($psi); @Matrix[$row[($a+180)]][$column[($b+180)]] += 1; }