מדרש אויף בראשית 38:29

וַיְהִ֣י ׀ כְּמֵשִׁ֣יב יָד֗וֹ וְהִנֵּה֙ יָצָ֣א אָחִ֔יו וַתֹּ֕אמֶר מַה־פָּרַ֖צְתָּ עָלֶ֣יךָ פָּ֑רֶץ וַיִּקְרָ֥א שְׁמ֖וֹ פָּֽרֶץ׃

און עס איז געװען, װי ער ציט צוריק זײַן האַנט, ערשט זײַן ברודער איז אַרױסגעקומען; האָט זי געזאָגט: װאָס האָסטו זיך געריסן מיט אַזאַ רײַסעניש? און מע האָט גערופֿן זײַן נאָמען פֶּרֶץ.

Midrash Tanchuma Buber

Another interpretation (of Gen. 39:1): WHEN JOSEPH WAS TAKEN DOWN TO EGYPT…. What is written above on the matter (in Gen. 38:29)? AND IT CAME TO PASS THAT, AS HE DREW BACK HIS HAND < … > [SO HIS NAME WAS CALLED PEREZ]. Here is kingship (according to Ruth 4:18): THESE ARE THE GENERATIONS OF PEREZ.68The biblical text continues with a genealogy from Perez to David. (Gen. 38:30:) THEN AFTERWARDS HIS BROTHER CAME OUT. Here is a priest. Then afterwards (in Gen. 39:1): WHEN JOSEPH WAS TAKEN DOWN TO EGYPT, the Holy One simply brought them the good news that, wherever they went, they would have the services of a king and a priest. How so? In Egypt < they had > a king and a priest, as stated (in Exod. 7:8): NOW THE LORD SAID UNTO MOSES AND UNTO AARON…. Also in their Exodus < they had a king and a priest > (according to Ps. 77:21 [20]): YOU LED YOUR PEOPLE LIKE A FLOCK BY THE HAND OF MOSES AND AARON.
פֿרעגט אַ רבֿBookmarkShareCopy

Bereshit Rabbah

“Her days to give birth were complete” (Genesis 25:24) – elsewhere18When Tamar gave birth (Genesis 38:27). they19The days of pregnancy. are incomplete, and here they are complete. Elsewhere it is written: “Twins [teomim]” (Genesis 38:27) – Peretz and Zeraḥ were both righteous, but here, “tomim” – Jacob was righteous, Esau, wicked.20The regular spelling is teomim. The midrash explains that a letter missingfrom the word indicates that something is amiss.
“The first emerged ruddy” (Genesis 25:25) – Rabbi Ḥagai said in the name of Rabbi Yitzḥak: Due to the merit of: “You shall take for you on the first day” (Leviticus 23:40),21The mitzva of the four species. I reveal myself to you first, as it is stated: “I am first and I am last” (Isaiah 44:6); I will exact retribution on your behalf from the first – that is Esau, as it is written: “The first emerged”; I will build for you the first – this is the Temple, in whose regard it is written: “Throne of glory, exalted from the first, [is the place of our Temple]” (Jeremiah 17:12); and I will bring you the first, this is the messianic king, in whose regard it is written: “The first to Zion, behold, here it is” (Isaiah 41:27).
Another matter, “the first emerged ruddy” – why did Esau emerge first? It was so he would emerge and his corruption would depart with him. Rabbi Abahu said: It is like that bathhouse attendant who washes the bathhouse and then bathes the king’s son. So, why did Esau emerge first? It was so he would emerge and his corruption would depart with him.22The womb would remain clean for Jacob.
A noblewoman asked Rabbi Yosei ben Ḥalafta, she said to him: ‘Why did Esau emerge first?’ He said to her: ‘The first droplet23Of semen. was Jacob’s.’ He said to her: ‘This is analogous to an instance where you place two pearls into one tube, is it not the one that you placed first that will emerge last? So, the first droplet was Jacob’s.’
“Ruddy,” Rabbi Abba bar Kahana said: As though he were a shedder of blood. When Samuel saw that David was ruddy, as it is written: “He sent and brought him and he was ruddy” (I Samuel 16:12), he was afraid and said: ‘This is a shedder of blood like Esau.’ The Holy One blessed be He said to him: “With beautiful eyes” (I Samuel 16:12). Esau killed at his own initiative, but this one kills at the initiative of Sanhedrin.
The emperor Diocletian was a swineherd near Tiberias. When he would come to the study hall of Rabbi,24Rabbi Yehuda Nesia, grandson of Rabbi Yehuda HaNasi. the children would go out and strike him. Sometime later, he became emperor, and he descended and resided near the Panyas; variant reading: Pamyas, and he sent directives to Tiberias just before nightfall on Thursday: ‘I decree that the prominent leaders of the Jews shall appear before me before morning on Sunday.’ He commanded the emissary and said to him: ‘Do not deliver them [the directives] to them until sunset on Friday.’ Rabbi Shmuel bar Naḥman went down to bathe. He saw Rabbi standing before the great study hall, and he saw that his face was sickly. He said to him: ‘Why is your face sickly?’ ‘Such and such directives were sent to me by the empire.’ He said to him: ‘Come and bathe, as your Creator performs miracles on our behalf.’ They entered to bathe, and the demon Arginiton came, and was laughing and dancing before them. Rabbi wanted to scold him. Rabbi Shmuel bar Naḥman said to him: ‘Leave him alone, as sometimes he appears for the purpose of miracles.’ He said to him: ‘Your master is in distress and you are standing, laughing, and dancing.’ He [the demon] said to them: ‘Go eat and drink and observe a fine Shabbat, as your Master will perform miracles on your behalf, and I will have you stand before him on Sunday morning.’ At the conclusion of Shabbat, after the service, he took them and stood them outside the gates of Panyas.
They [servants] entered and said to him [Diocletian]: ‘They are standing before the gates.’ He said: ‘Close the gates.’ He [the demon] took them [the Rabbis] and placed them on the city wall. They [servants] entered and told him [Diocletian]. He said: ‘I decree that they should heat the bathhouse for three days, and then they will enter, bathe, and come before me.’ They went and heated the bathhouse for three days, and one of the Arginiton demons entered and diluted it25With cold water. for them. They entered, bathed, and came before him. He said to them: ‘Because you know that your God performs miracles on your behalf, you belittle the emperor.’ They said to him: ‘We belittle Diocletian the swineherd, but we are subjugated to Diocletian the emperor.’ He said to them: ‘Even so, do not demean a young Roman, and not a low ranking soldier.’ “All of him like a cloak of [kaaderet] hair” (Genesis 25:25) – all of him is worthy of the cloak.
The Rabbis of the South in the name of Rabbi Alexandri, and Raḥava in the name of Rabbi Kahana said: He came out all unkempt and scattered like an aderet – like the chaff and the straw from the threshing floor [idera]. That is what is written: “Then the iron…were pulverized, and became like the chaff from the threshing floors [idrei] of summer” (Daniel 2:35). Rabbi Hanina bar Yithak said: What caused them to be pulverized? “From the threshing floors [me’idera] of the summer” (Daniel 2:35) – it is because they extended their hands against the great [adirim].26Israel.
“They called his name Esau [Esav]” (Genesis 25:25) – this is the falsehood [heh shav] that I created in My world. Rabbi Yitzḥak said: You called your swine a name, I, too, call My firstborn son a name: “So said the Lord: My son, My firstborn, is Israel” (Exodus 4:22).
פֿרעגט אַ רבֿBookmarkShareCopy

Aggadat Bereshit

[3] Another interpretation: "And Judah went down, etc., and he saw there a daughter of a Canaanite man and took her. Once he took her, the Holy One, blessed be He, said, 'The Messiah is destined to issue from Judah, and he went and took a Canaanite wife! What then shall I do? I will cause that she engage in improper conduct and have a son from her, and the son will marry my daughter Tamar, who is the daughter of the great Shem.' Said the Holy One, blessed be He, 'Let her die as a Canaanite,' as it is said, 'And the days were multiplied and she died, daughter of Shua, the wife of Judah' (Genesis 38:12). And her sons died, as it is said, 'And Er and Onan died' (Genesis 38:7)[from Onan: Genesis 38:10], so that Judah should cling to Tamar, who was the priestly daughter of Shem son of Noah, as it is said, 'And Melchizedek king of Salem' (Genesis 14:18). And it came to pass, as she was giving birth, that one put out a hand; and the midwife took and bound upon his hand a scarlet thread, saying, “This one came out first.” But it came to pass, as he drew back his hand, that, behold, his brother came out; and she said, “How hast thou broken forth? [i.e., breached the womb].” Therefore his name was called Perez. And afterward his brother came out that had the scarlet thread upon his hand; and his name was called Zerah (Genesis 38:27-30). At the time of Tamar's childbirth, Zerah sought to come out first. God said, "The Messiah will come from Perez." Zerah then emerged first, but later returned to his mother's womb, and Perez emerged first. The Messiah comes from Perez, as it is written, "And it came to pass, as he drew back his hand, that, behold, his brother came out: and she said, 'How hast thou broken forth?' Therefore his name was called Perez." This Perez is the Messiah, as it is written, "The breaker is come up before them" (Micah 2:13).
פֿרעגט אַ רבֿBookmarkShareCopy