my $fetch = sub { my ($fh) = @_; return if eof $fh; $_[1] = scalar <$fh>; return 1; }; ... while ($next->(my $item)) { print "$item\n"; } #### my $fetch = sub { my ($fh) = @_; return if eof $fh; return \(scalar <$fh>); }; ... while (my $ref = $next->()) { print "$$ref\n"; } #### my $fetch = sub { my ($fh) = @_; return if eof $fh; return scalar <$fh>; }; ... # RIGHT: while (my ($item) = $next->()) # WRONG: while (my $item = $next->()) while (my ($item) = $next->()) { print "$item\n"; }