
annak
New User
Jul 26, 2008, 4:42 AM
Post #1 of 1
(315 views)
|
|
access array in class method
|
Can't Post
|
|
Hi all, Please help me to find the problem. :) I have docTopGens class: package docTopGens; use wt_w;
sub new { my($self) = {}; my($type, @array) = @_; my $self->{'topGenArray'} = \@array; my $temp = ref($self->{'topGenArray'}); bless($self, $type); return($self); } here $temp = 'ARRAY'; the problem is that in the following method '$self->{'topGenArray'}' contains nothing and $temp ="; sub get_wt { my $doc_g = $_[1]; my $TopGenArray = $self->{'topGenArray'}; my $temp = ref($self->{'topGenArray'}); my $size = @{$TopGenArray}; for($i=0; $i<$size; $i++) { $wt_w = $topGenArray->[$i]; $id = $wt_w->getDocID(); if($doc_g eq $id) { return $wt_w->getPG_D(); } } return 0; } the question is how can I access '$self->{'topGenArray'}' in 'get_wt' function. outside this class the code looks as following: $topGen = new docTopGens @TopGensArray; my $wt = $topGen->get_wt($Doc_g); Thanks!
|