Just to clarify - if A.pm is executed as a script it defines several methods, but does not add A to
@INC. This is the root of the problem:
- B.pm looks at @INC (via either use or require), sees that A.pm is missing and tries to load it.
- A.pm gets loaded (it is not in @INC yet).
- Whilst loading A.pm, the perl compiler notices that those methods have already been defined in the namespace of A.
- Redefinition warnings are thus triggered.
See ikegami's post for a better way to pre-load from the command line.
Best, beth