Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: blessed confusion

by jethro (Monsignor)
on Sep 08, 2010 at 23:53 UTC ( #859443=note: print w/replies, xml ) Need Help??

in reply to blessed confusion

Clue 1: If you google for the error message or call "perldoc perldiag" on the command line you will find out that the error message means that your second argument to bless (your $package above) is a reference instead of a string with a class name in it. Check where the error occurs (line xxx) and retrace the program back to where $package gets its value. My guess is that you forgot to change something when you copied the code to create the 2nd derived class

Clue 2: in your URL class you bless $url to your class but never initialize it with anything. Maybe you had $up in mind (which gets initialized). Something similar seems to be happening in your derived class as well

Clue 3: Generous use of Data::Dumper to print out your data structures will give you insight in what you constructed. Check your variables whether they contain what you expect them to contain.

Clue 4: "perldoc perlobj" has lots of examples of the optimal use of object initialization (lines 40 to 90 for example). As you can see you have it almost right, only some bugs need to be corrected it seems

Replies are listed 'Best First'.
Re^2: blessed confusion
by perl-diddler (Chaplain) on Sep 09, 2010 at 03:35 UTC

    Talk about misdirecting error messages.

    It should have said I was trying to bless _with_ a 'non-classname'. When I see 'bless $reference,$name', I see it as _value_ in '$name' being written into the 'package-type' label for the object. So the 'ref' is receiving (being blessed) with the value. Error message then says that something is wrong with the 'target' of my

    Once I new the problem was with the 'classname' and not the target, problem was quickly found as prior level called 'new' as in:

    instead of:
    Thanks MUCH for pointing at the error message. I should have looked it up rather than expecting the wording to make sense. Now I have an idea why IBM et al, use ABEND3207. :-)

      Error message then says that something is wrong with the 'target' of my

      Just like a person is blessed into a church, a value is blessed into a class. What you call the target of the bless is on the left of "bless into".

      An alternate phrasing would be "Attempt to use reference for class name".

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://859443]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2018-06-21 23:34 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (120 votes). Check out past polls.