I have various subroutines that give me arrays of arrays. I have tested them separately and somehow when i write my main routine, I fail to make the program recognize my arrays. I know it's a problem of dereferencing, or at least i suspect it heavily.
The code is a bit long but I'll try to explain it:
my @leaderboard=@arrarraa; #an array of arrays
my $parentmass=$spect[$#spect]; #scalar
while (scalar @leaderboard>0) {
for my $i(0..(scalar @leaderboard-1)) {
my $curref=$leaderboard[$i]; #the program says here that there is an uninitialized value. But I start with a list of 18 elements.
my @currentarray=@$curref; #then i try to dereference the array
my $w=sumaarray (@currentarray);
if ($w==$parentmass) {
if (defined $Leader[0]) {
my $sc1=score (@currentarray);
my $sc2=score (@Leader);
if ($sc1>$sc2) {
@Leader=@currentarray;
}
}
else {@Leader=@currentarray;}
}
elsif ($w>$parentmass) {splice @leaderboard,$i,1;} #here i delete the element if it doesn't work. I hope it's done correctly.
}
my $leadref= cut (@leaderboard); #here i take the first 10 scores of the AoAs
@leaderboard = @$leadref;
my $leaderef=expand (@leaderboard); #then i expand the AoAs by one term
@leaderboard= @$leaderef; #and i should end with a completely different list to work with in the while loop
}
So I don't know how to dereference the AoAs correctly. The output of the program says:
"Use of uninitialized value $curref in concatenation (.) or string at C:\Algorithms\22cyclic\cyclospectrumsub.pl line 183. Can't use an undefined value as an ARRAY reference at C:\Algorithms\22cyclic\cyclospectrumsub.pl line 184."
I would appreciate enormously any insight or recommendation.