The stupid question is the question not asked | |
PerlMonks |
Re: Perl archeology: Need help in refactoring of old Perl code that does not use strictby Corion (Patriarch) |
on Nov 14, 2017 at 08:45 UTC ( [id://1203338]=note: print w/replies, xml ) | Need Help?? |
In addition to AnomalousMonks advice of a test suite, I would suggest at the very least to invest the time up front to run automatic regression tests between whatever development version of the program you have and the current "good" (but ugly) version. That way you can easily verify whether your change affected the output and operation of the program. Ideally, the output of your new program and the old program should remain identical while you are cleaning things up. Note that you can enable strict locally in blocks, so you don't need to make the main program compliant but can start out with subroutines or files and slowly convert them. For your second question, have a look at Exporter. Basically it allows you to im/export subroutine names between packages:
To find and collect the global variables, maybe it helps you to dump the global namespace before and after your program has run. All these names are good candidates for being at least declared via our to make them visible, and then ideally removed to pass the parameters explicitly instead of implicitly:
The above code is a rough cut and for some reason it claims all global names as scalars in addition to their real use, but it should give you a start at generating a list of undeclared names. Also see Of Symbol Tables and Globs.
In Section
Seekers of Perl Wisdom
|
|