Genesis 38:23-29
English Standard Version
24About three months later Judah was told, "Tamar your daughter-in-law has been immoral. Moreover, she is pregnant by immorality." And Judah said, "Bring her out, and let her be burned."
25As she was being brought out, she sent word to her father-in-law, "By the man to whom these belong, I am pregnant." And she said, "Please identify whose these are, the signet and the cord and the staff."
26Then Judah identified them and said, "She is more righteous than I, since I did not give her to my son Shelah." And he did not know her again.
27When the time of her labor came, there were twins in her womb.
28And when she was in labor, one put out a hand, and the midwife took and tied a scarlet thread on his hand, saying, "This one came out first."
29But as he drew back his hand, behold, his brother came out. And she said, "What a breach you have made for yourself!" Therefore his name was called Perez.