Siegfried Heintze wrote: > I'm trying to write a screen scraper and I need to use inheritance > (according to a response to an earlier post). > > > > Here is the original piece of code: > > > > my $parser = HTML::Parser->new(api_version => 3); > > > > Now how do I change this so it is creating an instance of my custom class? > > > > Here is my attempt to make a new class: >
John Doe's comments are dead on *if* you need to create your own constructor, which I am not certain you do. Are you planning on contributing your own default attribute values? Or are you merely going to be writing methods that extend the base class? Unless you are messing with the internals of the object itself (not through your methods) then you don't need to have your own constructor, that can be inherited as well. package CrawlCompanyJobPage; our @ISA = ('HTML::Parser'); And then, my $parser = new CrawlCompanyJobPage ('api_version' => 3); Should do the trick. No need to redefine 'new' *unless* you are going to add attributes specific to your package at construction time. [snip] > > Thanks, > > Siegfried > > Good luck, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>