in reply to keywords versus variables
The most obvious case would be the replacement of a single global variable with a scope-restricted variable and access methods for it. IMHO, this would be an improvement even if the code that uses those access methods needs additional temporary vars to work with it.
{ # scope of foo_tracker my $foo_count; sub found_a_foo() { ++$foo_count; } sub foo_count() { $foo_count; } sub killed_a_foo() { --$foo_count; } } # scope of foo_cache
That said, I do favor refactoring code to reduce the number of variables passed into a function, or the number of levels through which an argument is passed before it gets used.
|
|---|