my $iter = do { my $done = 0; sub { $done++ ? undef : 1 } }; iter_prod($iter, ...) if ...; iter_prod($iter, ...) if ...;