in reply to intercept nonexistent methods call

If you don't want how inheritance dispatches method calls, maybe inheritance is the wrong way?

Just create a separate class that inherits nothing and has an object of your "real" class. Give that class an AUTOLOAD method. In that AUTOLOAD method, log the calls and then either dispatch to the "real" class instance or whatever.

Replies are listed 'Best First'.
Re^2: intercept nonexistent methods call
by Bor (Beadle) on Aug 04, 2011 at 10:24 UTC
    Thank you for reply.

    Forgot to say: subclass - is a test mock module, so I have Module & Module::Mock.
    In tests I redefine like this
    local *Module::new = sub { Module::Mock->new(); };
    I want to see what methods called from this test module.
    And yes, you are right - maybe I not need inheritance from "real" class. Then I can control all methods calls.
      This is not working as I want :(
      If I comment "parent Module;" in Module::Mock.
      Then code
      local *Module::new = sub { Module::Mock->new(); };
      do not gives any effect and in other modules Module->new() calls.