BEGIN { ... read the levels that should be ON to %debug for (1.. $count_of_levels) { eval "sub LVL$_ () {$debug{$_}};"; } }