Usually, anything made with flour (other than bread) takes the before-bracha for flour: "mezonos". So, apple pie is made of flour (crust), apples, and sugar, and a usual size serving of apple pie takes the "mezonos" before-blessing. See, for example, http://berachot.org/foods/letter_a.htm for apple strudel or apple pie. The after-bracha for a perogi depends on how much you ate. Typically, a serving of perogi will contain enough flour (a k'zayis) so you should say the "al hamichya" after-blessing. If you ate a small piece of perogi, so you did not eat enough flour to warrant "al hamichya" but you did eat a k'zayis of perogi, then say the after blessing of "borei nefashos". If you eat less than a k'zais of perogi, and you eat no other foods, then no after-bracha is said. Even if you eat enough perogi for a full meal, you would not say Bircas Ha'mazon afterward because that blessing is said only on baked goods, not boiled. (See, for example, http://berachot.org/foods/letter_s.htm for spaghetti.) If you fried the perogi (which you did not say you were doing), the situation would become more complicated and less clear. (It might seem that berachot.org is taking a stand on this based on the entry for fried dough. But fried dough is really deep fried, which is considered boiling.) As an aside, it is very difficult to learn the laws of blessings. For reasons I do not understand, the several presentations of these laws that I have read are confusing in various details.