in reply to Carp croak not working when used in an imported function

Even though it's been imported (say into PkgB), errmsg was compiled in another package (say into PkgA). croak will skip over any calls within PkgA because that's where errmsg was compiled. It doesn't skip over the calls in PkgB.

A couple of ways around this:

package PkgB; sub errmsg { local $Carp::CarpLevel = $Carp::CarpLevel + 1; PkgA::errmsg(@_); }
or
package PkgB; our @ISA = 'PkgA';
or
package PkgB; our @CARP_NOT = 'PkgA';