{ package IterTest; use overload '<>' => \&iterator, fallback => 1; my $x = 0; sub new { return bless {}, shift; } sub iterator { print "Angefragt!\n"; if ($x++ < 10) { return $x; } else { return undef; } } } my $test = IterTest->new(); for my $num (<$test>) { print "$num\n"; }