Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have an OO parser in two classes Frontend and Backend::Frontend. Frontend inherits from Backend.
Backend parses a file and invokes Frontend::method via a callback for specific chunks of the input document. For instance, it may encounter an element named 'glark', so it calls Frontend::glark($args).
These Frontend methods transform the arguments in some way then either return a string, or recursively call a Backend method to break the input down further. An example of the latter is:
sub Frontend::glark { my ($self,$args) = @_; return 'glark='.$self->backend_method($args); }
This produces the expected output even for complex documents. The problem, I have discovered, is related to the calling of the parent class' methods by Frontend -- the method is invoked correctly, but, as you would expect, the Backend method is invoked on a Backend::Frontend object, which causes no end of problems.
Or, to put it another way:
I'm sure this problem just represents a basic misunderstanding of Perl OO. I can probably hack around it, but I'd like to know the Right Way. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OO Parser Class with Callbacks - Confusion
by merlyn (Sage) on Dec 04, 2006 at 03:32 UTC | |
by Anonymous Monk on Dec 04, 2006 at 03:45 UTC | |
by Anonymous Monk on Dec 04, 2006 at 04:05 UTC | |
|
Re: OO Parser Class with Callbacks - Confusion
by GrandFather (Saint) on Dec 04, 2006 at 03:07 UTC |