Static variable
#!/usr/bin/perl
use strict;
use warnings;
{
my $counter = 0;
sub inc {
$counter++;
return $counter;
}
}
print inc(), "\n";
print inc(), "\n";
print inc(), "\n";
print inc(), "\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 inc {
$counter++;
return $counter;
}
}
print inc(), "\n";
print inc(), "\n";
print inc(), "\n";
print inc(), "\n";