in reply to Creating Variables Just to Pass into Subroutine?
If it were me, I wouldn’t care if arguments were put into variables ... as long as those variables were local, not global, and as long as they were declared. This program is obviously very old. If it has a large set of global variables, those variables create “coupling” all over the place. If the variables are local, it actually might improve “at-a-glance readability” to use variables because each call to ampNotify() can be desk-checked visually.
I would start with the basics: adding use strict; use warnings; to the top of each module and checking for resulting compile-errors. Arrange the program into subroutines, or even in-line blocks, in which variables are local and declared with my.
Start now thinking about test-cases, e.g. Test::Most, by which you can verify what the program is doing now, at various levels, and ensure that the code does not “regress” (break ...) as you make changes to it.
Finally, get to know git, a version-control system that can work within a single directory or set of directories. Start by creating a repository out of the current directory and check-in the unchanged program. As you make each change, create a branch to make the change in, then merge the change back into the master-branch. Use a source-code editor of your choice with built-in support for git. In this way, you not only preserve a record for yourself of what changes you made and why, but you can also reliably revert the code to any prior state ... and “un-revert it again,” if you wish. Even if you are the one-and-only person who is working on the code, it’s a great tool to use.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating Variables Just to Pass into Subroutine?
by BrowserUk (Patriarch) on Jul 22, 2015 at 12:14 UTC | |
by SuicideJunkie (Vicar) on Jul 22, 2015 at 15:18 UTC | |
by Anonymous Monk on Jul 22, 2015 at 14:57 UTC | |
|
Re^2: Creating Variables Just to Pass into Subroutine?
by Anonymous Monk on Jul 22, 2015 at 16:50 UTC | |
by jeffa (Bishop) on Jul 22, 2015 at 16:54 UTC | |
by Anonymous Monk on Jul 22, 2015 at 17:43 UTC | |
by Anonymous Monk on Jul 22, 2015 at 18:05 UTC |