>>>>> "RW" == Ron Weidner <xecro...@yahoo.com> writes:
first off, arrays have nothing (or little) to do with OOP. you are using arrays inside an object but the code at that point is just plain perl. RW> In a module I have code that looks like this... RW> sub add_widget RW> { RW> my $self = shift; RW> my $new_widget = shift; RW> push ( @{$self->{WIDGETS}}, $new_widget ); RW> } RW> sub get_widgets RW> { RW> my $self = shift; RW> return $self->{WIDGETS}; RW> } RW> I'm writing a test that is failing at runtime with the following error. RW> Can't call method "attrib" on unblessed reference at ./test.pl line 40. RW> $config = new Widget(); you should call that with a direct method call and declare it with my. also config is a bad name for a widget object, even in an example. my $config = Widget->new(); RW> my $i = 0; RW> for ($i=0; $i<3; $i++) don't declare $i before the loop. it can be declared in it. also use perl style loops and not c style when you can: foreach my $i ( 0 .. 3 ) { RW> { RW> my $w = new Widget(); RW> $w->add_attrib("name", "widget".($i+1)); #add_attribute is tested and working you don't show that method. also your comment's method name doesn't agree with the actual method name. be consistant. RW> $config->add_widget($w); #this is what I'm testing and where is the code for this? RW> } RW> foreach my $w ( $config->get_widgets() ) RW> { RW> #attrib is tested and working, but this foreach loop is not known to be valid code yet. RW> print $w->attrib("name"); # <---- This is line 40. again, where is the code for this method? usually you can't debug method calls without seeing the method code. uri -- Uri Guttman -- uri AT perlhunter DOT com --- http://www.perlhunter.com -- ------------ Perl Developer Recruiting and Placement Services ------------- ----- Perl Code Review, Architecture, Development, Training, Support ------- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/