(Proverbs 13:16): "Every prudent man acts with knowledge" - this is one who does not grow proud in his Torah; "but a fool spreads out folly" - this is one who grows proud in his Torah. And likewise it says (Proverbs 13:20): "He who walks with the wise becomes wise." A parable: like one who enters the shop of a perfumer; even though he sells him nothing and buys nothing from him, he goes out and his scent wafts, and the scent of his garments is perfumed, and his scent does not depart from him all day long. Of him it says, "He who walks with the wise becomes wise." "But the companion of fools shall suffer harm" - a parable: like one who enters the shop of a tanner; even though he sells him nothing and buys nothing from him, he goes out, and his scent and the scent of his garments are foul, and the scent and the scent of his garments do not depart from him all day long. Of him it says, "But the companion of fools shall suffer harm." So too, anyone who walks with a wise man - whoever sees him says, "Were this man not wise, he would not be walking with a wise man like that one." And anyone who walks with a fool - whoever sees him says, "Were he not a fool, he would not be walking with the fool." Therefore it is said "But the companion of fools shall suffer harm."
Walking With the Wise Like Entering a Perfumer's Shop
Midrash Mishlei 13:1
... (משלי יג טז): "כל ערום יעשה בדעת" - זה שאינו מתגאה בתורתו, "וכסיל יפרוש איוולת" - זה שמתגאה בתורתו, וכה"א: (משלי יג כ): "הולך את חכמים יחכם". משל למי שנכנס בחנותו של בשם, אף על פי שאינו מוכר לו ואינו לוקח ממנו, הוא יוצא וריחו נודף, וריח בגדיו מבושמין, ואין ריחו זז ממנו כל היום, עליו הוא אומר "הולך את חכמים יחכם"; "ורועה כסילים ירוע" - משל לאחד שנכנס לחנותו של בורסקי, אף על פי שאינו מוכר לו ואינו לוקח ממנו, הוא יוצא, ריחו וריח בגדיו מלוכלכין, ואין ריחו וריח בגדיו זז ממנו כל היום, ועליו הוא אומר "ורועה כסילים ירוע". כך, כל מי שהוא מהלך עם חכם, כל מי שרואה אותו אומר 'אילולי לא היה זה חכם, לא היה הולך עם חכם כמותו', וכל מי שהוא הולך עם כסיל, מי שרואה אותו אומר 'אילולי שהוא כסיל לא היה הולך עם הכסיל', לכך נאמר "ורועה כסילים ירוע".