by reference and call by name semantics allow the parameters to act as aliases of the values passed as arguments, allowing the subroutine to modify variables outside its own scope. Static local variables A special type of local variable, called a static local, is available in many mainstream languages (including C/C++, Visual Basic, and VB.NET) which allows a value to be retained from one call of the function to another – it is a static variable with local scope. In this case, recursive calls to the function also have access to the (single, statically allocated) variable. In all of the above languages, static variables are declared as such with a special storage class keyword (e.g., static). Static locals in global functions have the same lifetime as static global variables, because their value remains in memory for the life of the program, but have function scope (not global scope), as with automatic local variables. This is distinct from other usages of the static keyword, which has several different meanings in various languages. Local variables in Perl Perl supports both dynamic and lexically-scoped local variables. The keyword local is used to define local dynamically-scoped variables, while my is used for local lexically-scoped variables. Since dynamic scoping is less common today, the Perl documentation warns that "local isn't what most people think of as “local”.". Instead, the local keyword gives a temporary, dynamically-scoped value to a global (package) variable, which lasts until the end of the enclosing block. However, the variable is visible to any function called from within the block. To create lexically-scoped local variables, use the my operator instead. To understand how it works consider the following code: $a = 1; sub f() { local $a; $a = 2; g(); } sub g() { print "$a\n"; } g(); f(); g(); this will output: 1 2 1 This happens since the global variable $a is modified to a new temporary (local) meaning inside , but the global value is restored upon leaving the scope of . Using my in this case instead of local would have printed 1 three times since in that case the $a variable would be limited to the static scope of the function and not seen by . Randal L. Schwartz and Tom Phoenix argue that the operator local should have had a different name like save. Local variables in Ruby Ruby as a language was inspired also