>$x and $y are in the same scope. This is good, but also bad. For one
>thing, you can hang yourself real easily if you come from a C background
>and expect this to keep stuff private:
> $x = 10;
> sub square {
> ($x) = @_;
> $x *= $x;
> }
> $ans = square($x);
> print "$x squared is $ans\n"; # "100 squared is 100" ?
>Ooops. What happened? Turns out the sub square()'s $x is the same $x as
>the one outside. Bad news, you reset the (global) value of $x. Ooops.
Perhaps you simply know inept C programmers. In C, something that
isn't declared auto or static is going to be global. Seeing no
scoping declarations, the C programmer who knows C will come to the
same conclusion as the Perl programmer, correctly understanding the
scope.
--tom