我正在做一个程序,它使用变量组合(combiData.txt 63 行 x 不同的列数)来分析数据表(j1j2_1.csv, 1000filas x 19 列),以选择每个组合在数据中重复的次数表以及来自哪些行(例如,tableData[row][4])。
我试图编译它,但是我收到以下消息:
Use of uninitialized value $val in numeric eq (==) at rowInData.pl line 34.
Use of reference "ARRAY(0x1a2eae4)" as array index at rowInData.pl line 56.
Use of reference "ARRAY(0x1a1334c)" as array index at rowInData.pl line 56.
Use of uninitialized value in subtraction (-) at rowInData.pl line 56.
Modification of non-creatable array value attempted, subscript -1 at rowInData.pl line 56.
nothing
这是我的代码:
#!/usr/bin/perl
use strict;
use warnings;
my $line_match;
my $countTrue;
open (FILE1, "<combiData.txt") or die "can't open file text1.txt\n";
my @tableCombi;
while(<FILE1>) {
my @row = split(' ', $_);
push(@tableCombi, \@row);
}
close FILE1 || die $!;
open (FILE2, "<j1j2_1.csv") or die "can't open file text1.txt\n";
my @tableData;
while(<FILE2>) {
my @row2 = split(/\s*,\s*/, $_);
push(@tableData, \@row2);
}
close FILE2 || die $!;
#function transform combiData.txt variable (position ) to the real value that i have to find in the data table.
sub trueVal($){
my ($val) = $_[0];
if($val == 7){ return ('nonsynonymous_SNV'); }
elsif( $val == 14) { return '1'; }
elsif( $val == 15) { return '1';}
elsif( $val == 16) { return '1'; }
elsif( $val == 17) { return '1'; }
elsif( $val == 18) { return '1';}
elsif( $val == 19) { return '1';}
else { print 'nothing'; }
}
#function IntToStr ( ) , i'm not sure if it is necessary) that transforms $ to strings , to use the function <eq> in the third loop for the array of combinations compared with the data array .
sub IntToStr { return "$_[0]"; }
for my $combi (@tableCombi) {
$line_match = 0;
for my $sheetData (@tableData) {
$countTrue=0;
for my $cell ( @$combi) {
#my $temp =\$tableCombi[$combi][$cell] ;
#if ( trueVal($tableCombi[$combi][$cell] ) eq $tableData[$sheetData][ $tableCombi[$combi][$cell] - 1 ] ){
#if ( IntToStr(trueVal($$temp )) eq IntToStr( $tableData[$sheetData][ $$temp-1] ) ){
if ( IntToStr(trueVal($tableCombi[$combi][$cell]) ) eq IntToStr($tableData[$sheetData][ $tableCombi[$combi][$cell] -1]) ){
$countTrue++;}
if ($countTrue==@$combi){
$line_match++;
#if ($line_match < 50){
print $tableData[$sheetData][4]." ";
#}
}
}
}
print $line_match." \n";
}