I think you misunderstood both your own problem as well as the purpose of typeglobs. Guessing by your example, I would say you are trying to figure out how to pass variables to subroutines - but you wrote one subroutine each for every global variable, rather than a single function that takes the variable as parameter. If I'm guessing right, then that's what the bottom half of your code should look like:
print_foo($foo1);
print_foo($foo2);
print_foo($foo3);
print_foo($foo4);
print_foo($foo5);
sub print_foo {
my ($var) = @_;
print "$var\n";
}
It's better to put subroutine definitions at the top of the program in order to reap the full benefit from
strict though.
Makeshifts last the longest.