g1smd - 3:42 pm on May 22, 2012 (gmt 0)
Returning "410 Gone" for the exact URLs previously used for those pages which are now removed from the site is a good idea.
However, the code you supplied returns "410 Gone" for any and every URL that does not exist, not just for those pages that that you are in the process of removing from the site.
This includes returning "410 Gone" for URLs which will come into use as new pages next week, next month and next year. You should not return "410 Gone" for those URLs.