The trouble is I'm almost positive that the reference IS indeed blessed. I double checked (and triple and etc.) all the relevant code, and when that didn't produce anything wrong, I used Data::Dumper and the Dumper method even reported that the reference was blessed! Here's the stuff, cut down, of course:
my $tableau; for my $p(0..6) { $tableau->[$p] = Pile->new({ max => 52 }); for (1..$p) { my $card = $deck->GetRandCard(); $card->state('down'); $tableau->[$p]->fill_pile($card); } my $card = $deck->GetRandCard(); $card->state('up'); $tableau->[$p]->fill_pile($card); } ... my $tab_imgs; my $i = 1; for(@$tableau) { ## Here's the line that's causing the problems -> my $c = ($_->cards())[0]->label(); my $photo = $canvas->Photo(-file => "$card_dir\\$c.$ext", -format => 'gif'); push @$tab_imgs, $canvas->createImage(50+$i++*50,500, -image => $pho +to); } # Stuff in pile.pm (tableau calls # new,fill_pile,get_rand_card) sub new { my $proto = shift; my $self = shift; my $class = ref($proto) || $proto; $self->{next} = 0; bless ($self, $class); return $self; } sub fill_pile { my $self = shift; my $cards = shift; $self->{cards} = [$cards,$self->{cards}]; } sub GetRandCard { my $pile = shift; my $card = ($pile->shuffle())->[0]; $pile->remove_card; return $card; } # oh, and before I forget, the data::dumper print up # this is of ($_->cards())[0], the thing that tries to call # label, but can't cause it's "not blessed" $VAR1 = [ bless( { 'state' => 'up', 'where' => bless( { 'next' => 0, 'max' => 52, 'cards' => [ bless( { 'state' = +> 'down', 'where' = +> $VAR1->[0]{'where'}, 'value' = +> '1', 'suit' => + 'h' }, 'Card' ) +, ##.. more stuff like this + ] }, 'Pile' ), 'value' => 'q', 'suit' => 's' }, 'Card' ), undef ];
I don't know if this will be enough, but I don't know what else may help short of giving a lot of code.
edited: Sat Jul 6 16:22:40 2002 by jeffa - title change (was: Help with error)
In reply to Help with unblessed object reference error by dimmesdale
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |