http://www.perlmonks.org?node_id=362029


in reply to (Golf) Tic Tac Toe

Before starting to think, let's just rewrite it to 139:
s//123 456 789 z147,258,369,159,357/;$p=X;sub d{/z/;print$`.$p;@_&&die@_} {d;1until<>=~/\d/&&s/$&/$p/g;/$p{3}/?d$p:/\d/?$p^=v23:d Tie;redo}