You can program the 8u2 by either using a ISP programmer such as Pocket AVR Programmer or directly over USB using the FLIPS software as documented
That saidIn reference to:
"hence I want to make a small circuit on perfboard with minimal components"
I would recommend getting Tiny AVR Programmer or alike to program ATtiny's and at use the ATtiny's directly for small specific tasks. Hence you can avoid the cost of the whole UNO if not needed. You can even emulate limited USB connection as done with the DigiSpark. They even support internal oscillator. So they often need now external parts. They can be often applied without PCB.