in reply to creating matrices for PDL module

May I recommend an editor (other than notepad) which may have improved indenting facilities?

The syntax error is your friend, if it tells you that ]; is bad, then it probably is. If not, then something near it is.

If you were to indent your code in a more clear fashion your code might look like this:

#!/usr/bin/perl -w use PDL; $matrixfile = $ARGV[0]; open(MATRIX, "$matrixfile") || die "Error: Can't open $matrixfile file for reading: $!\n"; @matrix = <MATRIX>; for(my $i = 0; $i < @matrix; $i ++) { $a = substr($matrix[$i], 0, 5); $b = substr($matrix[$i], 6, 5); $c = substr($matrix[$i], 12, 5); $d = substr($matrix[$i], 18, 5); $cd = substr($matrix[$i], 24, 5); my $dmat = pdl [ [ $a, $b, $c, $d], } ];

Instantly you'd see that maybe a closing bracket was missing off the my $dmat = pdl [ ... ]; command. And that the final curly brace should probably be swapped with the square bracket the syntax error is complaining about.

Update: posted solution here:

#!/usr/bin/perl -w use PDL; $matrixfile = $ARGV[0]; open(MATRIX, "$matrixfile") || die "Error: Can't open $matrixfile file for reading: $!\n"; @matrix = <MATRIX>; for(my $i = 0; $i < @matrix; $i ++) { $a = substr($matrix[$i], 0, 5); $b = substr($matrix[$i], 6, 5); $c = substr($matrix[$i], 12, 5); $d = substr($matrix[$i], 18, 5); $cd = substr($matrix[$i], 24, 5); my $dmat = pdl [ [ $a, $b, $c, $d], ] };