Hi Brian

Brian McKee wrote:
>
> I'm slowly creating my Perl Masterpiece (tm)
> I'll let ya all giggle over it when I'm done :-)

You shouldn't get any laughter from here. All of us have written
a less-than-acceptable Perl script.

> At any rate - It's done what I believe you call "top-down".

>From your following comments I thing you're getting confused between
your design and your source layout?

> I declare the subs, then have the code for the main program,
> then the subroutine code blocks.

Most of what matters is your thought process, not the layout of the
source. I've always thought something like 'outside-in' where the
majority of the code is at the level that the language prescribes,
but sometimes I need to add what I would call a 'primitive' that the
language doesn't provide directly, and often I need to describe a
'process' where a number of actions are called, often conditionally,
to provide a higher-level action.

> My question is what order should the subroutines appear in?
> Alphabetical?  Order of appearance? Rough grouping by function?
> The fact that some subroutines may or may not call other subroutines
> and some of the subs are called by pretty much all the other subs
> makes it hard for me to decide what order would make it easiest to read.

How much do you care about readability? I would aim first for something
that worked, while keeping in mind my own wishes for debugging, and then
reassess. Without any other input, I would guess that what is best for you
is also good for others. Just do a brain dump into an obviously-placed
text file before you hand over: explain the thinking behind the thing
you've built.

> What's the 'standard'?

There is none, apart from, 'do it well'. But I would hope to see
declarations of the subs before their definitions. Something like

#!perl

use strict;
use warnings;

use needed_modules;

sub mysub1;
sub mysub2;
sub mysub3;

main-line-code;

sub mysub1 {
  :
}
  :
etcetera
  :

__END__


but others will disagree :)

Take a look at

  perldoc perlstyle


HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to