Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Perl archeology: Need help in refactoring of old Perl code that does not use strict

by Monk::Thomas (Friar)
on Nov 14, 2017 at 12:14 UTC ( #1203365=note: print w/replies, xml ) Need Help??


in reply to Re: Perl archeology: Need help in refactoring of old Perl code that does not use strict
in thread Perl archeology: Need help in refactoring of old Perl code that does not use strict

This is what I would do after 'Step 0':

  • identify a function using a global variable.
  • verify the global variable does not change during execution of this function, e.g. some other function called by this function modifies it. (insert some code to do this for you)
  • convert global variable into an argument and update all callers.

If the variable does change during the run then pick a different function first. When you got the global state disentangled a bit it's a lot easier to reason about what this code is doing. Everything that's still using a global needs to be treated with very careful attention.

  • Comment on Re^2: Perl archeology: Need help in refactoring of old Perl code that does not use strict

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1203365]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2020-01-17 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?