The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package My::PersistentIterator;

my $iterator;

sub new { 
  my $self = shift;
  my $class = ref($self) || $self;
  $iterator ||= (bless {_num=>shift} => $class);
}

sub next {
  my $self = shift;
  $self->{_num}++;
}

1;