in reply to Whether to use local()
But more often than not, you just want to make your class
data a file-scoped lexical. To do so, simply put this at
the top of the file:
my $Census = 0;
Even though the scope of a my() normally expires when the
block in which it was declared is done (in this case the
whole file being required or used), Perl's deep binding of
lexical variables guarantees that the variable will not be
deallocated, remaining accessible to functions declared
within that scope. This doesn't work with global
variables given temporary values via local(), though.
YuckFoo
|
|---|