in reply to Re: How to export a package sitting lower in a module?
in thread How to export a package sitting lower in a module?
It works best if you put separate packages into separate files.
Sometimes (especially if you have an object-oriented project, with many little packages), it's not convenient to have each package in a speparate file.
So the solution is to add the export text (as Corion says) and then invoke import directly, i.e. pack_B->import.
Please note that this still doesn't work: the .pm module fails, complaining that the second @ISA is a bareword.
Main script:
The packages:use pack_A; pack_B->import; third();
# Name of this file: pack_A.pm package pack_A; use strict; require Exporter; @ISA = qw {Exporter}; @EXPORT = qw {first second}; sub first { } sub second { } 1; #end package pack_A; package pack_B; use strict; require Exporter; @ISA = qw {Exporter}; @EXPORT = qw {third fourth}; sub third { } sub fourth { } 1; #end package pack_B; #end of file pack_A.pm
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How to export a package sitting lower in a module?
by kennethk (Abbot) on Apr 22, 2013 at 15:38 UTC | |
by HelenCr (Monk) on Apr 22, 2013 at 20:00 UTC |