static variable (with scope)
- static
#!/usr/bin/perl
use strict;
use warnings;
{
my $counter = 0;
sub next_counter {
$counter++;
return $counter;
}
}
print next_counter(), "\n";
print next_counter(), "\n";
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
#!/usr/bin/perl
use strict;
use warnings;
{
my $counter = 0;
sub next_counter {
$counter++;
return $counter;
}
}
print next_counter(), "\n";
print next_counter(), "\n";