in reply to How do I make one package use a module from another package?
Well, its easy, just use the packages in the caller's namespace:
use Carp qw(croak); require Exporter; our @ISA = qw(Exporter); sub import { my ($pkg) = (caller)[0]; eval qq[ package $pkg; use strict; use warnings; use Whateverelseyouwant; ]; croak $@ if $@; # optionally, if you still need import: goto \&Exporter::import; }
Update: Added error handling.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I make one package use a module from another package?
by Anonymous Monk on Jul 22, 2003 at 22:29 UTC | |
|
Re: Re: How do I make one package use a module from another package?
by bobn (Chaplain) on Jul 22, 2003 at 22:23 UTC | |
by jryan (Vicar) on Jul 23, 2003 at 01:46 UTC | |
by bobn (Chaplain) on Jul 23, 2003 at 05:05 UTC | |
by jryan (Vicar) on Jul 23, 2003 at 05:39 UTC | |
by bobn (Chaplain) on Jul 23, 2003 at 13:32 UTC | |
|