I think you don’t really understand what programming is until you really understand how to package your code. There is a great tutorial from Hilary Parker and another one from Hadley Wickham.
I tried to redo the getout package in R using XML and RCurl package. You can see the source code here.