The last section of this Parsha presents many of the Halachos relating to the types of living creatures which we Jews are allowed and not allowed to eat (ויקרא פרק י"א). Among the creatures discussed here are those in the category of what we call "שרצים," literally meaning insects, or creeping or teeming creatures. Rashi (לפסוק י' שם) asserts simply that the term "שרץ" always refers to a lowly creature that creeps and crawls along the ground, a definition he echoes in his commentary several Pesukim later (פסוק כ' שם) as well as elsewhere in the Torah (דברים י"ד:י"ט); in commenting on a Posuk at the very beginning of the Torah (בראשית א':כ'), Rashi (שם בד"ה שרץ) writes that any living creature that does not rise high off the ground is called a שרץ, and he gives several examples, while the Ramban there (שם בד"ה ישרצו) stresses that a שרץ is a creature that moves about or creeps about constantly.
In our Parsha, the Torah refers to three categories of שרצים which are considered repulsive or unclean, and thus may not be eaten: creatures that teem in the water, each known as a שרץ המים (ויקרא שם פסוק י'), creatures that fly, like flying insects, but are four-legged, each known as a שרץ העוף (שם פסוק כ'), and creatures that creep upon the land, each known as a שרץ הארץ (שם פסוק כ"ט). Later in the Torah (דברים שם), consumption of any creature in the category of שרץ העוף is prohibited, without reference to the number of legs it has; although the Pesukim in our Parsha (ויקרא שם פסוקים כ"א-כ"ב) allow the consumption of certain insects, specifically, certain kinds of locusts, Rashi (לפסוק כ"א שם בד"ה ממעל) notes that today we lack the expertise to properly identify these insects, and consequently, we can not distinguish the permissible species from the forbidden ones. Although the Shulchan Aruch (יורה דעה סימן פ"ה סעיף א') allows one to eat certain kinds of insects, stressing the need for a firm tradition as to their permissibility, the Taz (שם ס"ק א') states that the current practice, at least among Ashkenazic Jews, is not to eat any of these creatures because of the problems concerning proper identification. The Ohr HaChaim, in his commentary on our Parsha (לפסוק כ"א שם בד"ה אשר לו כרעים), writes that one should stop people from eating any of these creatures, and that he himself abolished the practice among Jews in a certain land to eat certain such creatures. In general, the Torah states simply that we should not make ourselves disgusting by means of any of these creeping creatures called שרצים (ויקרא שם פסוק מ"ג).
In connection with those creatures in the category of שרץ הארץ, the שרצים that creep upon the ground, which the Torah says are disgusting and may not be eaten (שם פסוק מ"א), the Gemara in Chulin (דף ס"ז.-ס"ז:), presents the opinion of the Amora Shemuel that if a worm or, presumably, any kind of insect, grew inside a particular vegetable while it was still attached to the ground, one may not eat the vegetable, because by doing so, he will also be eating this worm or insect, which would be in violation of this prohibition to eat a שרץ הארץ, found in the Posuk in our Parsha (שם). It is clear from Rashi's explanation of the Gemara (עמוד ב' שם בד"ה באביה) that in order for an insect or a worm to be considered forbidden, it must actually creep on the ground, in which case it is indeed viewed as a שרץ which is "על הארץ," "on the ground," as the Posuk (שם) mentions when formulating the prohibition. Consequently, if the worm or insect develops in the vegetable while it is still attached to the ground, and it moves around inside it, it is viewed as though it is indeed creeping along the ground, and it is thus forbidden. Rashi (שם) concludes by noting, however, that if the worm developed in the fruit or vegetable after it was already detached from the ground, and it is now somewhere inside the fruit or vegetable, it may be eaten as long as it does not come outside.
The Gemara (שם) then points out a contradiction, quoting one opinion that insects and worms which develop in certain vegetables and fruits may be eaten, an opinion quoted as well by the Sifra on our Parsha (פרק י"ב הלכה א' ועיין שם בפירוש הראב"ד בד"ה וכל), and explained by Rashi (שם בד"ה להוציא) to be based on the fact that these insects and worms are not "על הארץ," "on the ground," but instead are inside the vegetable (or fruit), and then citing another opinion, also found in the Sifra (שם הלכה ב' ועיין שם בפירוש הראב"ד בד"ה בכל), that worms found in the roots of certain vegetables or fruits may not be eaten. The Gemara (שם) first resolves the contradiction by distinguishing between whether the insect or worm grew inside the fruit or vegetable while it was still attached to the ground, in which case it is forbidden, in accordance with the view of Shemuel cited above, or whether it grew after it was detached, in which case it is permitted. The Gemara (שם) then states, however, as explained by Rashi (שם בד"ה אידי), that the distinction may actually be between whether the insect or the worm which developed inside the fruit or vegetable ever came outside of it, in which case it is forbidden, or whether it remained inside, in which case it is permissible, even if it developed while the fruit or vegetable was attached to the ground, and there is thus no proof from these cases to the stricter position of Shemuel. It is clear, however, from Rashi here (שם בד"ה פירשה) that everyone agrees that if the worm develops inside the fruit or vegetable after it has been detached, it is permissible as long as it never came outside of it; Rashi earlier in Chulin (דף נ"ח. בד"ה אסורה) spells out the reason for this very clearly. The Gemara (שם דף ס"ז:) then introduces several other scenarios regarding the appearance of worms and insects in fruits or vegetables, and leaves the question of whether in these cases they may or may not be eaten unresolved.
As pointed out in Tosafos in Chulin (שם בד"ה דיקא), there is also some question about whether this stricter ruling of Shemuel referred to above, that if the worm or insect appears in the fruit or vegetable while it is still attached to the ground it is automatically forbidden (even if it never comes outside), is accepted as the Halacha or not. According to Tosafos (שם), although Rabbeinu Tam and the Riva, among others, hold that this position is not accepted, the Behag (ספר הלכות גדולות, סוף סימן ס"ב, הלכות דגים) along with Rav Achai Gaon, in his Sheiltos for our Parsha (פ' שמיני, שאילתא פ"ד), rule that this position is accepted, and if the worm grows while the fruit or vegetable is still attached to the ground, it is prohibited. This is also the opinion of the Raavad, in his commentary to the Sifra cited above (להלכה א' שם בד"ה וכל), as well as of the Rif in Chulin (דף כ"ג:-כ"ד. בדפיו), who clearly state that the Halacha is in accordance with the opinion of Shemuel; the Ran (דף כ"ג: שם בד"ה והוי) agrees to this view as well, and explains the position and how it relates to the Gemara in Chulin (שם) clearly. The Shiltei HaGiborim (שם אות ג') thus writes that any fruit (or vegetable) which can regularly have worms (or insects) in it while it's attached to the ground must be checked before being eaten. The Rashba, in his Sefer Toras HaBayis (בית שלישי, סוף שער שלישי, דף פ"ד.) also accepts Shemuel's opinion that if the worms or insects develop while the fruit or vegetable is still attached to the ground, they are forbidden, and so do the Semag (מצות לא תעשה קל"ב), the Baal HaIttur (ספר העיטור חלק ב', שער ראשון, הכשר הבשר, דף י"ב:) and others. Although the Mordechai in Chulin (סימן תרמ"ג, דף ד. בדפיו) states that Rashi, in a Teshuvah, agreed with those who held that the Halacha does not follow Shemuel, a position held as well, according to the Hagahos HaAsheri on the Rosh in Chulin (פרק ג' סימן ס"ח בד"ה אבל בא"ז), by the Ohr Zarua (חלק א' סימן תל"ז), who quotes others who agree to this, including the Raavyah, he also quotes (שם סימן תרמ"ד) others who ruled in accordance with Shemuel. This is the ruling of the Tur (יו"ד סימן פ"ד) as well, and the Beis Yosef (שם בד"ה והגדלים ובד"ה ולענין הלכה כיון שהרי"ף...) asserts that this stricter position is indeed the Halacha since it is accepted by the overwhelming majority of Poskim.
The Rambam (פרק ב' מהל' מאכלות אסורות הלכה י"ד) writes that those species of insects or worms which grow inside fruits or vegetables and then crawl outside may not be eaten even if they have crawled back into the fruit or the vegetable, but if they never came outside, they may be eaten when one eats the fruit or the vegetable. He then adds (שם הלכה ט"ו), however, that this is true only if the worm or the insect developed in the fruit or the vegetable after it was detached from the ground, but if it developed while the fruit or vegetable was still attached to the ground, the worm or the insect is forbidden in any case, even if it never came outside; the Maggid Mishneh (להלכה י"ד שם) notes that the Rambam too accepts the position of Shemuel. This is also the ruling found in the Shulchan Aruch (יו"ד שם סעיף ו' ועיין שם בביאור הגר"א ס"ק ט"ז); the Shulchan Aruch earlier (שם סעיף ד') rules, however, that worms which grow in fruits once they have been detached are permissible as long as they never came out of the fruit. It should be noted that the Sefer HaChinuch (מצוה קס"ג) writes that even in this case, eating such things should be discouraged because it is disgusting. The Rambam (שם הלכה ט"ז) also states that in all the situations presented in the aforementioned Gemara in Chulin (שם) which were left unresolved regarding insects or worms found in various fruits or vegetables, consumption of those items is forbidden; the Maggid Mishneh (שם) states that because this prohibition is MideOraisa, the Halacha must be in accordance with the stricter viewpoint in any case where there is a question, and the Shulchan Aruch (שם), as explained in the Be'er HaGolah (שם אות ז'), rules this way as well because the prohibition is MideOraisa.
It should be noted that the Ramo (שם סעיף ט') rules that there is no fruit (or vegetable) which has a worm (or insect) inside it that does not have "ששים," that is, a 60:1 ratio of the fruit (or vegetable) itself against the forbidden taste of the worm (or insect), and certain leniencies are thus possible if one already cooked the fruit or vegetable; the Shach (שם ס"ק ל') and the Taz (שם ס"ק ט"ו) discuss whether or not this depends on the size of the particular fruit or vegetable. These leniencies are based on the idea presented by the Gemara in Avodah Zarah (דף ס"ט.) that in a mixture containing some forbidden item, if the ratio of the permitted part of the mixture to the forbidden part is 60:1, the forbidden part is considered nullified (בטל בששים), and the entire item may be eaten; the Rambam (פרק ט"ו שם הלכה ו') and the Shulchan Aruch (יו"ד סימן צ"ח סעיף א') rule accordingly. It must be stressed, however, that this principle of nullification (ביטול) does not allow us to ignore the problem of insects or worms in fruits and vegetables altogether on the assumption that there will always be enough of the fruit or vegetable to nullify the forbidden insect or worm. The Shulchan Aruch later (שם סימן ק' סעיף א'), based on a later Gemara in Chulin (דף צ"ט:-ק., ועיין בדף ק. שם בתוד"ה בריה), rules that a בריה, that is, an independent creature, can not be nullified, meaning that an independent creature, no matter how small it is and no matter how many times larger than it the mixture, in this case the fruit or the vegetable, which it is found in is, remains forbidden, because MideRabbanan, as noted by the Taz (שם ס"ק א'), nullification does not apply to a בריה. Rav Yonasan Eybeschutz (ספר כרתי ופלתי על שולחן ערוך יו"ד שם ס"ק ד' בפלתי) suggests, however, that perhaps the worm or insect in a fruit or a vegetable does not qualify as a בריה because it is missing one of the qualifications for a בריה listed in the Shulchan Aruch (שם), since it is not forbidden at the moment it comes into existence in the fruit or the vegetable. But he concludes (שם) that one should nevertheless not be lenient about this, and the Chavas Daas (ליו"ד שם ס"ק ד' בביאורים), by the author of the Nesivos HaMishpat, rejects the entire suggestion, noting that the Gemara in Makkos (דף ט"ז:-י"ז.), after stating that by eating one small insect, one can violate as many as five or six different prohibitions at once, says that such an insect is indeed called a בריה. The Dagul MeRevavah (לסימן פ"ד שם, נדפס עם חדושים בסוף שו"ע יו"ד חלק א') seems to agree that an insect found in a fruit or a vegetable may not qualify as a בריה, saying that one should be able to rely upon this and accept the leniencies which result from this view, but he then writes that this idea goes against the opinion of the Ran in Chulin (דף י"ט: בדפי הרי"ף בד"ה וכ"כ הרמב"ם) who indicates that an insect is considered a בריה. The Pri Megadim (בשפתי דעת לסימן פ"ד שם ס"ק ל"א) asserts that this is the view of most Poskim; Rav Ovadyah Yosef (שו"ת יחוה דעת חלק ו' סימן מ"ז בהערה) quotes authorities on each side of this issue, and concludes that most hold that such an insect or a worm is in fact a בריה. There is thus no room to say that insects or worms inside a fruit or vegetable are permitted based on the principle of nullification (ביטול).
In light of all of the above, it is clear that one must avoid consuming insects that grow in fruits or vegetables. The Rambam (פרק ב' שם הלכה ט"ו) rules that if there is any doubt about where the insect developed (whether inside or outside the fruit or vegetable) or about when it developed (whether while the fruit or vegetable was attached to or detached from the ground), and there usually is such a doubt because it is hard to tell much about the insect when it is seen, we must assume that it can not be eaten. The Shulchan Aruch (יו"ד שם סעיף ז') rules accordingly, and the Shach (שם ס"ק כ"א) adds that we must be strict even if a particular fruit or vegetable is not known to develop worms or insects, as long as one sees them there now. The Rambam (שם) thus writes that one must inspect a fruit thoroughly in order to ascertain that there are no insects or worms in it; the Shulchan Aruch (שם סעיף ח') says this as well. It is thus clearly necessary to check one's fruits and vegetables for insects thoroughly before consuming them. Rav Moshe Feinstein (שו"ת אגרות משה יו"ד חלק א' סימן ל"ה ושם חלק ב' סימן כ"ה) asserts that one must thoroughly inspect vegetables that are likely to have insects or worms in them, and that it is preferable, though not required, to check other vegetables that are less likely to have such creatures in them; he adds elsewhere (שם אורח חיים חלק ד' סימן צ"א אות ג') that each type of produce is different in terms of the likelihood of its having insects in it, and thus the details of how to check and who may do the checking can vary.
It is interesting to note that Rav Yaakov Emden (שו"ת שאילת יעב"ץ חלק ב' סימן קכ"ד) implies that it may be better to examine one's fruits or vegetables with a magnifying glass or a microscope, but he concludes that this is an excessive stringency not to be imposed on the community. The Chochmas Adam, in his Sefer Binas Adam (כלל ל"ח אות ל"ד ]מ"ט[) rules, however, that one need not use a magnifying glass at all because the Halacha is concerned only with what is visible to the naked eye; the Aruch HaShulchan (יו"ד שם סעיף ל"ו) rules this way as well, asserting that no magnifying glass should be used, and the Darkei Teshuvah (שם ס"ק צ"ד) appears to concur as well. Rav Ovadyah Yosef (שו"ת יחוה דעת שם) quotes others who agree to this, and he insists that this is unquestionably the Halacha, and one must therefore examine his produce thoroughly, but with no more than one's own eyes. It goes without saying, however, that one must be aware of what one is looking for, and since certain insects, because of their color, blend in with the fruit or the vegetable, while others can easily be mistaken for a speck of dirt, one must acquire a certain amount of expertise in order to be able to examine one's produce properly. It should be noted that the Aruch HaShulchan (שם סימן ק' סעיפים י"ג-י"ח) tries to defend the practice of people over the years who were not that meticulous about examining fruits and vegetables for insects, but it should also be noted that the Sifra (שם הלכה ד') equates one who carefully observes these laws about שרצים with one who affirms and understands the meaning of Yetzias Mitzrayim, while one who fails to observe these laws properly is likened to one who denies the message of Yetzias Mitzrayim. It must also be added that the Chayei Adam, in his explanation of the וידוי, the confession, recited on Yom Kippur (סוף כלל קמ"ג, בביאורו למילה "אשמנו"), asserts that there is hardly a person or a household which does not violate the prohibitions relating to שרצים regularly, presumably because insects are so frequently found in fruits and vegetables, and people are not sufficiently conscientious concerning the fulfillment of these Halachos. One should obviously try, therefore, to improve one's level of commitment to these laws.