Next | Program Repair Shop | 113 |
Here we pay the costs of strict without collecting the benefits
my($each_sub, %out_subs, %left_out, $ver, $real_sub_entry_found, %final_out_subs, %out_subs, $separate_hash_entry_opt, $long_subname, @final_separate_entry_out);
Fix (a): Get rid of strict. (Don't put it in just because people say you should.)
Fix (b): Restructure the program to use better encapsulation and smaller scopes
For example, $long_subname is used only inside the elsif block
That is where it should be declared:
} elsif ( $lib[$j]=~/^(\#+ *title *: *([\w\-\.]+))/i ) { my $long_subname=$1; my $sub_name=$2; $title_found=1;
Exercise: Which of the strict effects is most valuable? Which is least valuable?
Next | Copyright © 2002 M. J. Dominus |