in reply to Objects, callbacks and XML::Parser
I also note that you appear to be using references to methods as the handlers, while XML::Parser expects non-method subroutines. The only reason this might sortof work (as in - not break immediately) is that you declare $self in the same scope as the methods. I might be mislead here, since I can't read the code you left out.
In any case, the real problem is somewhere in the lines you left out.
as a side note: using new ClassName has it's problems. If you want to be sure you call a class method instead of any random new() subroutine that happens to be in scope, use ClassName->new() instead.
update: are you using use warnings or the -w switch? that should warn on sharing lexial context in named subroutines. In other words, you will have the $self from the first call to new() in the later calls. This is a known problem in perl, but it's also debatable what the correct solution should be. (since named subroutines are global objects). See this part of the mod-perl docs for more info
|
|---|