in reply to Re: Proper syntax for using a method as a call back routine?
in thread Proper syntax for using a method as a call back routine?

That isn't going to work. As soon as the method containing the the call to $parser->handler() exits, (or the nearest local scope), then the value assigned to $instance will be forgotten as the global $instance reverts to its former value and whne the _add_link() routine is called back by the parser, $instance could have just about any value.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


  • Comment on Re: Re: Proper syntax for using a method as a call back routine?

Replies are listed 'Best First'.
Re: Re: Re: Proper syntax for using a method as a call back routine?
by dws (Chancellor) on Jul 08, 2003 at 03:17 UTC
    That isn't going to work.

    I assumed that the parser would be called on to do its thing within the scope of the current method. If that's not the case, consider stashing $self into a package variable.

      I assumed that the parser would be called on to do its thing within the scope of the current method.

      In which case, it would work, and I'm talking out my lower lumbar region again :)

      Needless to say, I assumed that it wouldn't be called until later, which was the case when I 'discovered' this problem, and after falling foul of trying to push and pop instance handles for multiple instances, arrived at the work-around of passing a ref to a closure around a call to the method.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller