- or download this
use Iterator;
my $i = 0;
...
print "Before calling anything: $i\n";
print "First call yields: ", $iterator->value, "\n";
print "After first call: $i\n";
- or download this
Before calling anything: 0
First call yields: 1
After first call: 1
- or download this
Before calling anything: 1
First call yields: 1
After first call: 2
- or download this
use Iterator;
my $i = 0;
...
print "Got b ($i)\n";
print "First value is ($i):\n";
print "b: ", $b->value, " ($i)\n";
- or download this
Now I will get_b (0):
Got b (0)
First value is (0):
b called
a called
b: 0 (1)
- or download this
Now I will get_b (0):
a called
b called
...
b called
a called
b: 0 (3)