in reply to Re: Can't call method "foo" on unblessed reference
in thread Can't call method "foo" on unblessed reference
If you don't mind could you please take a look at Tam's Chinese Peg Game. That's should explain some of the why's and how's of data structures I am mangling. :)package board; ... use lib('.'); use hole; # # new - board constructor # # holes ) is an ref to a array of hole objects # This is not typically passed in to the # constructor. The constructor will build # the holes attribute $holes is not passed. # # level ) is also not typically used. # sub new { my ($pkg, $holes, $level) = @_; unless ( $holes ) { # # create the holes # ... } my $obj = bless { holes => $holes, # ref to array of holes level => defined( $level ) ? $level : 0 }, $pkg; return $obj; } sub getHoles { my $obj = shift; return wantarray ? @{$obj->{'holes'}} : $obj->{'holes'}; ... 1; }
| Plankton: 1% Evil, 99% Hot Gas. |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Can't call method "foo" on unblessed reference
by Roy Johnson (Monsignor) on Jun 16, 2004 at 18:10 UTC | |
by Plankton (Vicar) on Jun 16, 2004 at 18:19 UTC | |
by Roy Johnson (Monsignor) on Jun 16, 2004 at 18:34 UTC | |
by Plankton (Vicar) on Jun 16, 2004 at 18:50 UTC |