A 22-year-old university student has narrowly avoided jail for beating a man unconscious over some hot chips.

Daniel Anthony Erbe appeared in Perth Magistrates Court on Monday and pleaded guilty to one count of assault occasioning bodily harm for the attack in the CBD in October last year.

The court heard Erbe approached the victim - a stranger to him - who was eating hot chips as he sat in an alleyway outside the Amplifier Bar.

When Erbe reached over to grab some chips, the victim pulled them away, saying: "Who the f*** do you think you are?"

Erbe then began punching the victim with both fists until he was unconscious.