in reply to Re^2: 'my' problems
in thread 'my' problems
You have your answers below, but I'd thought I'd post a simple example, which shows quite explictly that the 'my' does scope a variable, but doesn't re-initialise it if you have a conditional which evaluates to false.
print count() . "\n"; print count() . "\n"; print count() . "\n"; sub count { my $counter = 'whatever' if 0; # declare local 'static' variable $counter++; } __OUTPUT__ 0 1 2
PS. Don't actually do this though
|
|---|