Genesis 38:28-30 New American Standard Bible (NASB)

28. Moreover, it took place while she was giving birth, one put out a hand, and the midwife took and tied a scarlet thread on his hand, saying, "This one came out first."

29. But it came about as he drew back his hand, that behold, his brother came out. Then she said, "What a breach you have made for yourself!" So he was named Perez.

30. Afterward his brother came out who had the scarlet thread on his hand; and he was named Zerah.

Genesis 38