mirg drol has asked for the wisdom of the Perl Monks concerning the following question:
I'm not very good at Perl (yet, i hope) and i was wondering if there's a way to create a sub that behaves like a built-in function.
This is my situation:
I have a module "global" in which a sub "compress" is defined. I use this module from the main package, and my program calls other modules at runtime. Is there a way to make the "compress" behave like a built-in function so that i don't have to use the "global" module from the called modules?
It uses different files:
- GLOBAL.pm: in which the compress sub is stored - script.pl: the main script - module_a.pm: some random module which uses compress - module_b.pm: etc.
I guess i have to use the Exporter module in some way, but that only seems to let a package that uses the "global" module.
Is this a 'correct' way to program or is it morally wrong and should i just use "GLOBAL->compress" instead of trying to call it with "compress" each time?
Thanks in advance! ;]
This is my situation:
I have a module "global" in which a sub "compress" is defined. I use this module from the main package, and my program calls other modules at runtime. Is there a way to make the "compress" behave like a built-in function so that i don't have to use the "global" module from the called modules?
It uses different files:
- GLOBAL.pm: in which the compress sub is stored - script.pl: the main script - module_a.pm: some random module which uses compress - module_b.pm: etc.
I guess i have to use the Exporter module in some way, but that only seems to let a package that uses the "global" module.
Is this a 'correct' way to program or is it morally wrong and should i just use "GLOBAL->compress" instead of trying to call it with "compress" each time?
Thanks in advance! ;]
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Create a built-in-like sub?
by Juerd (Abbot) on Feb 01, 2002 at 09:16 UTC | |
by mirg drol (Initiate) on Feb 01, 2002 at 10:00 UTC | |
by Necos (Friar) on Feb 01, 2002 at 11:26 UTC | |
by Juerd (Abbot) on Feb 01, 2002 at 23:45 UTC | |
by CharlesClarkson (Curate) on Feb 01, 2002 at 11:22 UTC | |
by chromatic (Archbishop) on Feb 01, 2002 at 17:43 UTC | |
by mirg drol (Initiate) on Feb 05, 2002 at 14:27 UTC | |
Re: Create a built-in-like sub?
by Biker (Priest) on Feb 01, 2002 at 09:59 UTC | |
Re: Create a built-in-like sub?
by (Sexton) on Feb 01, 2002 at 20:47 UTC | |
Re: Create a built-in-like sub?
by dragonchild (Archbishop) on Feb 11, 2002 at 13:30 UTC |
Back to
Seekers of Perl Wisdom