Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Class::Std problem

by Herkum (Parson)
on Jan 19, 2009 at 04:38 UTC ( #737210=perlquestion: print w/replies, xml ) Need Help??
Herkum has asked for the wisdom of the Perl Monks concerning the following question:

I was running my code and came across this error which was really bizarre.

Can't call method "isa" on an undefined value at /usr/local/share/perl +/5.8.8/Class/ line 225.

The problematic code is,

# This is the values that blow it up # @hierarchy = qw(EEBL::League::Schedule); # @hierarchy = qw(EEBL::Team EEBL EEBL::Config); return @{$_hierarchy_of{$class}} = sort { $a->isa($b) ? -1 : $b->isa($a) ? +1 : 0 } @hierarchy;

Does anyone have any ideas on how i can work around this?

Update: My actual solution for this ended up being using another version of Perl on this box (5.10). I don't think the source of my problem was the code but something in the interpreter(5.8.8 on Linux ubuntu

Replies are listed 'Best First'.
Re: Class::Std problem
by ikegami (Pope) on Jan 19, 2009 at 04:56 UTC

    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;

      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.

Re: Class::Std problem
by kyle (Abbot) on Jan 19, 2009 at 16:50 UTC

    Does one of those classes (EEBL::*) have a sub isa that clobbers $a or $b?

      I was pretty sure that would be a no, and double-checked. I did not accidentally create my own isa() routine.

      Something that I had not thought about though.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://737210]
Approved by planetscape
[choroba]: I don't know. Maybe a new capability will be given to Hermits?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2018-06-22 08:05 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (122 votes). Check out past polls.