in reply to Scalars within Subroutines (scope)

The reason it is bad is not because you use the same names, but because you are using the special variables $a and $b. Now, there is really no harm, but you still should not use these variables as lexical variables. They are reserved for sort.

There is nothing wrong with using the same names, however, because they are indeed in different scopes.

Update: i should add that when you declare a subroutine below declared variables, those variables are visible to the scope of that sub:

my $foo = 'bar'; baz(); sub baz { print $foo, "\n"; print $qux, "\n"; } my $qux = 'bar';
Try moving the declaration of $qux above baz() and see what happens after running that code. However, note that when you declare a variable named $foo or $qux inside sub baz with my, they are different variables.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)