require 'generator' l = ["junk1", 1, "junk2", 2, "junk3", "junk4", 3, "junk5"] g = Generator.new { |g| l.each { |e| g.yield e unless e =~ /^junk/ } } g.next # => 1 g.next # => 2 g.next # => 3