in reply to Re^2: Global Vars
in thread Global Vars
Nice technique. It seems to me that it's a handy step on the way to splitting things off into modules and/or object-oriented bits. Since all the references go through your global hash anyway, when you split off a function/module/object, the code in your subroutines wouldn't have to change much:
BEFORE
AFTERmy %my_global_values = (foo=>0, etc=>0); my $rGlobals = \%my_global_values; sub zigafoo { $rGlobals-> = 7 }
...roboticuspackage barbaz; my %my_package_values = (foo=>0); my $rPackage = \%my_package_values; sub foobar { $rPackage->{foo} = 7; }
|
|---|