assist/control has asked for the wisdom of the Perl Monks concerning the following question:
Hello! First post here.
How is it that package->import imports package into the caller?
I know that I can do the following:
{ package Base; use strict; use warnings; sub import { strict->import; warnings->import; } } { package A; use Base; # Now A has strict and warnings }
… but how does that work? Why is it that Base::import{… strict->import;} is the same as {package A; use strict;}?
Is there an implicit argument to import that’s being passed that tells it to import into the calling package? Or am I misunderstanding a core aspect of use/import behavior?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: import() into caller
by tobyink (Canon) on Jun 16, 2023 at 05:39 UTC | |
|
Re: import() into caller
by hv (Prior) on Jun 16, 2023 at 12:04 UTC | |
|
Re: import() into caller
by NERDVANA (Priest) on Jun 16, 2023 at 16:58 UTC | |
|
Re: import() into caller
by NetWallah (Canon) on Jun 16, 2023 at 04:30 UTC | |
by Anonymous Monk on Jun 16, 2023 at 04:42 UTC |