You find having ALL variables used outside subs shared EASIER TO DEBUG? Might be the case for simple CGI scripts, or programs of which the entire source fits on a single screen, but it has bitten many people.
Even Merlyn puts his subs last in his Web Techniques columns, which are deliberately aimed at instructing others on how to do things the right way.
And I think
merlyn does it the wrong way. Besides, what
merlyn does isn't automatically the right way to do it. Actually, I find much of his code written in an awful style, but I guess he'd say the same when reading my code. (OTOH, it's really hard to have good style when you're writing simple stand-alone web applications.)
As for the program logic you describe at the end of your post, I've seen real good, and very stylish programs like this:
my $qwerty;
# Description
{
my ($foo, $bar);
code;
code;
code;
}
# And now we're going to ...
{
my ($xyzzy);
code;
code;
}
# Etcetera...
{
code;
code;
code;
}
, which is great to look at, easy to read and very maintaible. You could do the same with a lot of closures, and thus bundle subs with the location of use.
44696420796F7520732F2F2F65206F
7220756E7061636B3F202F6D736720
6D6521203A29202D2D204A75657264
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.