June 2005
Beginner
480 pages
10h 31m
English
Now that you know about scope, there are some things that can be done effectively only with scope. One is recursive subroutines, and the other is the use strict Perl statement that enables a stricter Perl, possibly preventing you from making mistakes.
Perl version 4 didn't have private variables. Instead, Perl 4 had variables that were “almost private.” This concept of almost-private variables is still around in Perl 5. You declare these variables by using the local operator, as in this example:
sub myfunc {
local($foo)= 56;
# rest of function...
}
In the preceding snippet, $foo is declared to be local to the myfunc() subroutine. A variable that has been declared with local acts almost identically ...
Read now
Unlock full access