Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How do you give functions private variables that retain their values between calls?
How do you give functions private variables that retain their values between calls?
✍: Guest
Create a scope surrounding that sub that contains lexicals.
Only lexical variables are truly private, and they will
persist even when their block exits if something still
cares about them. Thus:
{ my $i = 0; sub next_i { $i++ } sub last_i { --$i } }
creates two functions that share a private variable. The
$i variable will not be deallocated when its block goes
away because next_i and last_i need to be able to access it.
2013-09-25, 2164👍, 0💬
Popular Posts:
How to make elements invisible? Change the "visibility" attribute of the style object associated wit...
Can two catch blocks be executed? No, once the proper catch section is executed the control goes fin...
What invokes a thread's run() method? After a thread is started, via its start() method of the Threa...
Enable ASP.NET polling using “web.config” file Now that all our database side is configured in order...
Write out a function that prints out all the permutations of a string. For example, abc would give y...