in reply to Subroutines versus straight top to bottom scripts

The reusability comes on two levels - in-script, and inter-script. In-script means that you might want to do the same thing several times in your script, and subroutines would be useful for that. Inter-script means that you can reuse some of this script's code for that script.

So yes, subroutines greatly aid reusability, on both levels.

Additionally, subs are easier to test than a top-down script. You only have to extensively test one sub at a time - once it's clean, you're confident to use it. Writin unit test is also simpler for subroutines with well defined interfaces than for whole scripts.

  • Comment on Re: Subroutines versus straight top to bottom scripts