in reply to Scalars within Subroutines (scope)
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:
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.my $foo = 'bar'; baz(); sub baz { print $foo, "\n"; print $qux, "\n"; } my $qux = 'bar';
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)
|
|---|