I'm toying with the idea of modifying my home-made test suite to supply it anonymous subroutines as command-line arguments.
The reason why I want to do this is to enhance the script's flexibility. It doesn't seem worth it to hard-code a subroutine that I am only going to use once or twice to assimilate the data in a particular manner.
At the same time I realize that supplying anonymous subs is not a good idea due to a host of issues ranging from syntax-checking to ensuring proper scoping.
The question has two parts:
- Is this idea sensible?
- What alternatives can I capitalize on to achieve my stated objective?
The test suite currently runs off the command line (fed in via Getopt::Long
).
$ ./testSuite.pl --option params --someFlag --anotherFlag --moreOptions params
Each test generates directories and files, which I want to analyze in one form or another:
diff
fileA in all directories at the end of the tests- Tabulate the data in all fileB's and print to screen
- Collate an obscure value in fileX of a subset of directories which match required criteria.
The idea of a dispatch table or pre-defined subs appeals if I'm certain of the functionality I need ahead of time. However, this isn't the case here.