On Tuesday, July 16, 2002, at 07:18 , Martin A. Hansen wrote:
> for the sake of order and logic, i want to split my perl script into two
> files.
>
> what is the smart way to do this?
[..]
you really should not put temptation in the way of some....
So i will try to avoid the 'down the middle' gags....
plan A:
segment it into components that actually work
as executbles on their own - so that one can have
mother_script:
require daughter1.pl
require daughter2.pl
....
my $answer1 =`daughter1.pl`;
....
which would be an old style model from the darkest pits
of 'scripting' - but complies with your basic idea.
plan B: as you isolate out functions that can be re-used
then shift them off into a module and learn
how to do the standard perl 'code reuse' method.
mother_script:
use FOO::BAR qw/:special/;
....
my $answer1 = get_from_daughter1();
In either case, what you are trying to do in the 'mother_script'
is isolate the 'core algorithm' in a simple and readable manner
by containing 'long, boring, technical bits' in 'subs' that are
elsewhere - but noted in the comments -
cf: the standard suite from perldoc perl about
perlsub Perl subroutines
perlmod Perl modules: how they work
perlmodlib Perl modules: how to write and use
perlmodinstall Perl modules: how to install from CPAN
HTH.
some illustrations and kvetching you will find at:
http://www.wetware.com/drieux/CS/lang/Perl/PM/PMbasics.html
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]