use Data::Dumper; my @array; # read from the file handle line by line while() { chomp; # split each line by ',' and save # corresponding records into the @recs array my @recs = split /\,/; # loop through the records array.. for (my $i; $i < @recs; $i++) { # and save I-th record in array # array[I]. Use @{..} to let push() know # that array[I] is also an array. push @{$array[$i]}, $recs[$i]; } } print Dumper(\@array); __DATA__ A,B,C D,B,C E,C,C #### $VAR1 = [ [ 'A', 'D', 'E' ], [ 'B', 'B', 'C' ], [ 'C', 'C', 'C' ] ];