In the toledoth that begins at Gen 6:9, what does it mean to say Noah was “perfect in his generations”?

The sentence is: “Noah was a just man and perfect in his generations, and Noah walked with God.” This does not mean he was perfect, full stop, because of the drunkenness incident, and because he died. Besides, surely “walking with God” does not require absolute perfection. Surely too God would not require a standard of Abram, whom God instructed, “be thou perfect” (Gen 17:1). Let us look to the Hebrew: the word is תָּמִים or tamim, glossed as “complete, sound.” Applied to men, this often means something like “possessed of integrity.” But why “in his generations”? Does the word mean the same here as earlier in the same verse? The Hebrew word is different: דּוֹר, dor, glossed “period, generation, dwelling”; it was confusing and misleading for the KJV to use the same word “generation,” because whereas toledoth can refer to offspring, dor cannot. So we should not say that the meaning is that Shem, Ham, and Japheth were singled out as tamim. The same issue arises with Gen 7:1, where God tells Noah, “Come thou and all thy house into the ark; for thee have I seen righteous before me in this generation [dor again].” An apparently better interpretation is supplied by, for example, NASB’s terse “blameless in his time” and the NIV’s more explicitly interpretive “blameless among the people of his time.”