Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^4: How to export a package sitting lower in a module?

by HelenCr (Monk)
on Apr 22, 2013 at 14:53 UTC ( #1029898=note: print w/replies, xml ) Need Help??

in reply to Re^3: How to export a package sitting lower in a module?
in thread How to export a package sitting lower in a module?

Corion: note that the two packages are sitting in the same module file.
Like I said, it's not straightforward to export from a package which sits lower in a module. Please try to run this module: it doesn't work - it gives errors:
# Name of this file: 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
with the main script:
use pack_B;
# or use pack_A; ?

Replies are listed 'Best First'.
Re^5: How to export a package sitting lower in a module?
by Corion (Pope) on Apr 22, 2013 at 14:56 UTC

    That's how use works. It works best if you put separate packages into separate files.

    If you don't want to do that, but still want to use Exporter, you have to call pack_B->import yourself, just like use describes.

    use pack_A; # implicitly calls pack_A->import() pack_B->import(); # explicitly call pack_B->import()

    But maybe you really do not want to have both, pack_A and pack_B in a single file?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1029898]
[Corion]: ambrus: Ugh - yes, that really sucks!
[stevieb]: good thing is that both sides of the break are completely frozen, so I was able to shut off the water to the building before any water leaks. I told the landlord last year to insulate that specific area better
[Corion]: stevieb: Our SV overlords don't know what "frozen pipe" means and think it's something like "frozen yogurt"
[ambrus]: huh... what does "SV" mean there?
[Marshall]: stevieb wish you well with water problems, my water was off all day Monday for repairs. Any more progress on .exe info problem?.
[stevieb]: Marshall: no. I commented on the thread yesterday. Visual Studio updates the tags ok, but corrupts the exe

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2016-12-08 18:12 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (144 votes). Check out past polls.