use strict; use warnings; use Data::Dumper; use Text::Levenshtein qw(distance); my $file=$ARGV[0]; my @all_ids=(); open my $in, "<", $file or die "Failed to open $file: $!"; while(<$in>) { chomp $_; push @all_ids, $_; } close $in; my @matrix; foreach my $first( @all_ids ) { my @row; foreach my $second( @all_ids ) { push @row, distance( $first, $second ); }; push @matrix, \@row; }; print Dumper(\@matrix);