in reply to Class::Std problem

That can't be. If @hierarchy only contained one element as you claim it does in the first data set, the compare block would never get called. @hierarchy actually contains more than one element, one of which is undefined.

To see the contents of @hierarchy, you can use

use Data::Dumper; print Dumper \@hierarchy;

Replies are listed 'Best First'.
Re^2: Class::Std problem
by Herkum (Parson) on Jan 19, 2009 at 05:36 UTC

    I used Data::Dumper to print out @hierarchy. That was how I got the array sample data in the original post. Since I have not debugged Class::Std before I was not sure if this was correct behavior or not.

    Since you are implying it is not, I guess that part needs further looking in to.

    The other thing was I also included code that returned @{$hierarchy_of{$class}} = @hierarchy When it was only a one element array. I still got the same error, which was why I listed two arrays as part of the problem.

      Sorry, but something you said isn't true.

      >perl -we"@hierarchy = qw(EEBL::League::Schedule); () = sort { $a->isa +($b) ? -1 : $b->isa($a) ? +1 : 0 } @hierarchy;" >perl -we"@hierarchy = qw(EEBL::Team EEBL EEBL::Config); () = sort { $ +a->isa($b) ? -1 : $b->isa($a) ? +1 : 0 } @hierarchy;" >

      According to you, code that isn't even executed is issuing a run-time warning.

      >perl -we"() = sort { die } 1" >perl -we"() = sort { die } 1,2" Died at -e line 1. >

      Find what and you found your problem. The most likely by far is that the content of @hierarchy isn't what you think it is.

      I used Data::Dumper to print out @hierarchy.

      Please provide the output. Remember to use Dumper(\@hierarchy) and not Dumper(@hierarchy). Flattening the array makes the output ambiguous.

        Here, is the output that I got from debugging. (Count was used to show the number of elements in the array, so that no undefined elements are sneaking in).

        Dumper $VAR1 = [ 'EEBL::League::Prospect', 'EEBL', 'EEBL::Config' ]; Count: 3 Dumper $VAR1 = [ 'EEBL::Team', 'EEBL', 'EEBL::Config' ]; Count: 3 Can't call method "isa" on an undefined value at /usr/local/share/perl +/5.8.8/Cla + ss/Std.pm line 228. Dumper $VAR1 = [ 'EEBL::Team', 'EEBL', 'EEBL::Config' ]; Count: 3 (in cleanup) Can't call method "isa" on an undefined value at +/usr/local + /share/perl/5.8.8/Class/Std.pm line 228. Dumper $VAR1 = [ 'EEBL::League::Schedule' ]; Count: 1

        I have used Class::Std a lot, and this is the first time I came across this sort of error. I think it just might be a interpreter error because this program was working on another box. I was hoping someone would have any idea of how to work around it without me having to reinstall/update Perl on the machine.