in reply to Testing of exception during import

G'day Dirk80,

You may already be aware of this, but in case not, I thought I'd point out that your import routine will not be called if your module is loaded like this:

use My::Test ();

See the use function, in particular:

"... there is a distinction between omitting LIST (import called with no arguments) and an explicit empty LIST () (import not called)."

It's possible that you have an "XY Problem" here. If you provided some information about the specific problem you're trying to solve, we may be able to offer other (better) solutions.

— Ken

Replies are listed 'Best First'.
Re^2: Testing of exception during import
by Dirk80 (Pilgrim) on Jul 05, 2022 at 08:59 UTC

    Thank you all for your answers. The problem was that simple. I fully understood your answers and everything works fine. I'm really glad about this great community and that you help me even if I have sometimes beginner questions.