my $d = [[],[], [], []]; #### sub pushsome { my $AoAref = shift; for (my $i = 0 ; $i <= $#_ ; $i++) { push @{$AoAref->[$i]}, $_[$i]; } } #### while ( ) { chomp; pushsome $d, split /,/; } #### #!/usr/bin/perl use strict; use warnings; use PDL; use PDL::Matrix; sub pushsome { my $AoAref = shift; for (my $i = 0 ; $i <= $#_ ; $i++) { push @{$AoAref->[$i]}, $_[$i]; } } sub fetchdata { my $file = shift; my @AoA; open(DATA, $file) || die "Error: Unable to open $file:$!\n"; while () { chomp; pushsome \@AoA, split /,/; } close DATA; PDL::Matrix->pdl(\@AoA); } # main program @ARGV or die "Please supply a data file on the command line!\n"; my $d = fetchdata( shift ); # ...