Your problem does not show anything related to inheritance - the code shows no relation between Person and Employee.
If you want to do a global capturing of all warnings raised by code in the Employee class, you will need to store the "current" Employee instance in a global variable and then reuse that variable in your %SIG handler for warnings. The easiest approach is to set the "current" employee in the main program:
local $Employee::current= $secondObject; $secondObject->doSomethingThatRaisesWarnings();
Note that your statement of
local $SIG{__WARN__} = sub { ... }
loses its effect as soon as Employee.pm has been compiled. This may or may not be what you want.
Personally, I would recommend to avoid capturing warnings in such a global way. I think it's better to have your Employee (or Person) class implement a ->logMessage() or ->warn() method that will store the warning with the employee.
In reply to Re^3: Inheritance without defining the object on inherited module
by Corion
in thread Inheritance without defining the object on inherited module
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |