[Phoenix-pm] poll: top or bottom?
Brock
awwaiid at thelackthereof.org
Fri Apr 7 16:38:48 PDT 2006
I think I got into the habit of putting a sub called main() at the
bottom through influence of C and Pascal. In Pascal you can't do it any
other way.
That said, I don't stick to it consistently, and sometimes my main logic
(which might only be a few lines) I put outside of anything right at the
top.
But I've not been known for my "Best Practice"s. :)
--Brock
On 2006.04.07.16.02, Metz, Bobby W, WCS wrote:
| It's Perl so anything goes and we won't shoot you for it, well some of
| us anyway.
|
| That said, "bottom" to your 1st ? and "no" to your 2nd. I find those
| folks who came from a C background or studied programming more in
| college tend to start with functions @ the top. I was one of those, but
| I always eschewed having to scroll through pages of code just to get to
| the begining, search features or not. But that's just me.
|
| B
|
| -----Original Message-----
| From: phoenix-pm-bounces+bwmetz=att.com at pm.org
| [mailto:phoenix-pm-bounces+bwmetz=att.com at pm.org]On Behalf Of Corey
| Saltiel
| Sent: Friday, April 07, 2006 1:55 PM
| To: phoenix-pm at pm.org
| Subject: [Phoenix-pm] poll: top or bottom?
|
|
|
| Where do you guys place your subroutines in scripts?
|
| And what do you usually prefer to call the subroutine that kicks things
| off,
| i.e. 'main()', 'begin()'?
|
| I've always put my subroutines at the top, right after the basic setup
| logic
| ( declaring pragmas and modules, and whatever global vars, etc ), then I
|
| throw the call to the entering/main subroutine at the very bottom of
| the
| script, underneath the subroutines -- but I tend to be switch between
| calling the entering subroutine either: main() or begin() - out of sheer
|
| indecision.
|
| Like so:
|
| #!/usr/bin/perl
| use warnings;
| use strict;
|
| use ACME;
| use Blah;
|
| my ( $globals, $go, $here ); # minimal or non-existant
|
| $globals = '';
|
| $go = '';
|
| $here = ''
|
|
| sub foo { }
|
| sub bar { }
|
| sub snafu {}
|
| sub begin {}
|
|
| begin();
|
|
| Anyhow, just curious! Obviously mostly a matter of subjective opinion,
| but
| interesting none-the-less.
|
|
| Beers,
|
| Corey
| _______________________________________________
| Phoenix-pm mailing list
| Phoenix-pm at pm.org
| http://mail.pm.org/mailman/listinfo/phoenix-pm
| _______________________________________________
| Phoenix-pm mailing list
| Phoenix-pm at pm.org
| http://mail.pm.org/mailman/listinfo/phoenix-pm
More information about the Phoenix-pm
mailing list