Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
sorry monks, I feel like this is info I should be able to find somewhere but I cant.
I have lots of subroutines, many of which use various modules or other subroutines I've made.
I use require 'myperlsub.pl' to include my subroutines and of course 'use' to include modules. What I would like to do is put 'use' and 'require' statements into my subroutines, since sometimes they will be called from scripts that already use and require the necessary subs and modules and sometimes not.
I've read that 'require' will handle double declarations just fine, but I've also read that I should use 'do myperlsub.pl' instead.
I can't find anything that says one way or the other how 'use' will handle this.
Please advise. Thanks.
I have lots of subroutines, many of which use various modules or other subroutines I've made.
I use require 'myperlsub.pl' to include my subroutines and of course 'use' to include modules. What I would like to do is put 'use' and 'require' statements into my subroutines, since sometimes they will be called from scripts that already use and require the necessary subs and modules and sometimes not.
I've read that 'require' will handle double declarations just fine, but I've also read that I should use 'do myperlsub.pl' instead.
I can't find anything that says one way or the other how 'use' will handle this.
Please advise. Thanks.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: use and require inside subs
by tachyon (Chancellor) on Nov 02, 2004 at 23:37 UTC | |
by elwarren (Priest) on Nov 03, 2004 at 00:48 UTC | |
by tachyon (Chancellor) on Nov 03, 2004 at 01:00 UTC | |
by halley (Prior) on Nov 03, 2004 at 14:43 UTC | |
by elwarren (Priest) on Nov 03, 2004 at 16:54 UTC | |
by Ytrew (Pilgrim) on Nov 03, 2004 at 04:15 UTC | |
by ysth (Canon) on Nov 03, 2004 at 07:01 UTC | |
by Anonymous Monk on Nov 03, 2004 at 06:25 UTC | |
by premchai21 (Curate) on Nov 03, 2004 at 07:36 UTC | |
Re: use and require inside subs
by Tuppence (Pilgrim) on Nov 02, 2004 at 23:57 UTC | |
Re: use and require inside subs
by JediWizard (Deacon) on Nov 02, 2004 at 23:37 UTC | |
Re: use and require inside subs
by kiat (Vicar) on Nov 02, 2004 at 23:41 UTC |
Back to
Seekers of Perl Wisdom