Предположим, где у вас есть:
$features{$cui} = 1;
Вы имели в виду:
$attributes{$cui} = 1;
Это упрощенная версия вашего кода:
use warnings; use strict;
use List::MoreUtils qw'uniq';
use autodie;
sub OutputingReorderedVectors{
my($centroids,$fileName,$chainRollupDoc) = @_;
my @reorderedSS;
for my $i( sort keys %$chainRollupDoc ){
push @reorderedSS, sort keys %{$chainRollupDoc->{$i}}
}
# NOTE: @reorderedSS is NOT sorted, only parts of it are.
my @fullSpace;
for my $category (values %$centroids){
push @fullSpace, keys %$category
}
@fullSpace = sort uniq @fullSpace;
open my $output, '>', $fileName;
print {$output} join( "\t", '', @reorderedSS ), "\n";
for my $i (@fullSpace){
print {$output} $i;
for my $j (@reorderedSS){
# could possibly be replaced with a simple print statement
printf {$output} "\t%f", $centroids->{$j}->{$i};
}
print {$output} "\n";
}
close $output;
}
Если вы далинам пример ваших данных и ожидаемый вывод этих данных, мы могли бы помочь вам в дальнейшем.
Я хотел бы отметить, что вы программируете на Perl, как если бы это был C .