in reply to Help with unblessed object reference error

UPDATE:
Of course! Thanks chromatic.

Okay. Here's cards method from pile.pm

sub cards { my $self = shift; if (@_) { $self->{cards} = shift } return $self->{cards}; }

I did the split up thing, jeffa, but still same problem (everything works but $card->label();)

# here's some more code if it helps sub label { my $self = shift; return "$self->{suit}$self->{value}"; } sub remove_card { my $self = shift; splice @{$self->{cards}}, 0, 1; } # Fisher-Yates shuffle sub shuffle { my $self = shift; use integer; my $i; for ($i = int(@{$self->{cards}}); --$i; ) { my $j = int rand ($i+1); @{$self->{cards}}[$i,$j] = @{$self->{cards}}[$j,$i]; } return $self->{cards}; }

Replies are listed 'Best First'.
Re: Re: Help with unblessed object reference error
by fokat (Deacon) on Jul 06, 2002 at 17:23 UTC
    Hmmm. My guess then would be that in the line where you do your $card->label(), $card does not have what you expect. Care to print "card=$card\n" just before the call to ->label()?

    Regards.