I'm relatively new to perl subroutines but first learned to program in C/C++. In C/C++, you are required to have an int main(){} function. I would typically declare all of my variables inside main() by default, and these variables would be invisible to any other functions. I would therefore be required to pass these variables as arguments if I wanted to use them (or just their values) inside of a function.
In perl, it seems that all variables are visible to all functions by default, i.e. they have global scope. Because perl does not require you to have a main function as C/C++ does, what do people typically do as a safeguard to make sure all variables aren't automatically visible to all subroutines? Or do people even typically bother with this?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |