> Bryan R Harris wrote: >> >> I'm not even sure how to ask this question, but here goes: >> >> I struggle knowing how to structure my code, what things belong as their own >> subroutines and what things can stay in the main script. How do the smart >> guys make these decisions? >> >> For example, let's say I need to: >> >> 1. Read a complex file >> 2. Populate a complex dataset >> 3. Accept user input >> 4. Based on user input, either modify or add to dataset, or quit >> 5. Update files on disk >> 6. Go to step #3 >> >> Which steps should be their own subroutines vs. just writing them into the >> main part of the script? And how did you make that decision? >> >> Seems like a waste to do step 2 in a subroutine since we only do it once, >> but it does fill the main body of the script with code-noise that makes it >> harder to debug overall logic problems... Not much logic here, but >> certainly in more complex scripts. >> >> Any suggestions? Where can I read more on this stuff? What questions >> should I be asking that I'm not smart enough to ask? >> >> TIA. >> >> - Bryan > > Well, there is one school of programming that insists that no subroutine > should be larger than 42 lines (see, it is the answer to everything).
Let me guess, the number of lines on a standard terminal in the old days? =) > I would separated the user I/O and the dataset I/O into their own > modules so that future changes to them will be isolated. Makes sense. - Bryan -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
