Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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


Comment on Re: blessed confusion
Re^2: blessed confusion
by perl-diddler (Hermit) 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 blessing...so...

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

    $this=URL::Fetchable::Open(@_);
    instead of:
    $this=URL::Fetchable->Open(@_);
    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 blessing...so...

      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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://859443]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-12-26 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls