I have a 2-D array stored as an object, when i go to call up the array using
it gives me the error
Can't use string ("0") as an ARRAY ref while "strict refs" in use.
Currently I am trying to print the objects (the code is in the package code).
When I try to do the same thing in my main code, it also gives the same error.
I'm not exactly sure what is wrong at this point, any thoughts are welcome.
is the object code in question, if that helps
Code:
my $testvar = @ {$self->Peptides};
Can't use string ("0") as an ARRAY ref while "strict refs" in use.
Currently I am trying to print the objects (the code is in the package code).
When I try to do the same thing in my main code, it also gives the same error.
I'm not exactly sure what is wrong at this point, any thoughts are welcome.
Code:
sub Peptides {
my ($self, @peptides) = @_;
my (@newpep, @temp);
# @peptides is considered a 3D Array with
# dimensions of i: 1, j: no. of peptides, k: 7 (data about peptides colleted)
#This will reformate the array correctly
if (defined @peptides) {
for my $i ( 0 .. $#peptides ) {
my $ref = $peptides[$i];
for my $j ( 0 .. $#{$ref} ) {
my $reef = $peptides[$i][$j];
for my $k (0 .. $#{$reef} ) {
#add element from peptides to list @temp
push @temp, $peptides[$i][$j][$k];
} #@temp should now be in the format (hitID, mass, delta, sequence, mod, score)
if ($#temp != 6) { shift @temp;} #formatting issue with the first item in the array
# add @temp to 2-d array @newpep
push @newpep, [ @temp ];
@temp = undef; # clear temp for next iteration.
}
}
$self->{_Peptides} = @newpep;
return $self->{_Peptides};
}#end if
#no peptide data passed
return $self->{_Peptides};
}
Comment