sub getmatrix { my $what = shift; my @matrix; while () { chop; if (/^0-9 ]/) die "Not a legal matrix row!\n"; } push @matrix, split / /; } return @matrix; }