in reply to Help: Constructors and all things OO.

Ok, taking it slow ...

The new() function should return the blessed object. It appears that return $class is returning the class, and not the object.
The message you have ("cant locate object method 'new' via package iXML::TheConstruct") appears to have something to do with the way the new method is being called. from what you have, i am guessing it should be :
use iXML::TheConstruct; use strict; my $obj = iXML::TheConstruct->new(); # ... get $html and $index $obj->add($html,$index); $output = $obj->output; #... do something with output.
Does something like this work ? If a use lib '' is needed, that can be understood, but make sure you still have the use statement. I would also suggest using strict, warnings (or -w), and diagnotics on the test script to see if you can get any more information.
can't sleep clowns will eat me
-- MZSanford

Replies are listed 'Best First'.
Re: Re: Help: Constructors and all things OO.
by IOrdy (Friar) on Aug 28, 2001 at 17:01 UTC
    As above ++thanks. you where correct about returning the class instead of the blessed object.

    And yes I hope for it to work as you have stated above. I do have use strict; and -w (this is where I get the errors from).

    As far as I can see there are no problem or spelling mistakes at all. Apart from the obvious that is :)
      What i would suggest then, is wittling you code down into just what is needed to add one (hard coded) entry, and print the output (similar to the test code i used above). If this does not work, please post the code and output (messages i mean). If this does work, then start down the "what's diffrent ..." path. This is usually how every debugging sojourn starts.
      can't sleep clowns will eat me
      -- MZSanford
        This is the code I made to call the module iXML::TheConstructor;
        #!/usr/bin/perl -w use lib '/usr/home/iordy/perl.iordy.net'; use strict; use Apache::Request; use iXML::TheConstruct; my $r = Apache->request; my $constuctor = iXML::TheConstruct->new();


        it works up until I add the ref my $r = Apache->request; so I tried it with XML::XPath and HTML::Template and it works fine which leads me to beleive something must be happening with Apache when I use my module. Depending on which I load first with 'use' the other comes up with the error "unable to find method 'new' via Module.".